[javascript] implement the api call to fetch information about all ships
This commit is contained in:
parent
2ae1d4e8fd
commit
4551c1a2dd
1 changed files with 9 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue