1
0
Fork 0

[javascript] implement the api call to fetch information about all ships

This commit is contained in:
Julien Dessaux 2023-09-10 22:02:32 +02:00
parent 2ae1d4e8fd
commit 4551c1a2dd
Signed by: adyxax
GPG key ID: F92E51B86E07177E

View file

@ -1,5 +1,4 @@
import * as api from './api.js';
import * as dbConfig from '../database/config.js';
import * as dbShips from '../database/ships.js';
import * as dbSurveys from '../database/surveys.js';
import * as systems from '../lib/systems.js';
@ -152,6 +151,15 @@ export async function sell(ctx) {
return response;
}
export async function ships() {
const response = await api.send({endpoint: `/my/ships`, page: 1});
if (response.error !== undefined) {
throw response;
}
response.forEach(ship => dbShips.setShip(ship));
return response;
}
export async function ship(ctx) {
const response = await api.send({endpoint: `/my/ships/${ctx.symbol}`});
if (response.error !== undefined) {