From 4551c1a2dd020b6807aca2db90729cd74af9ed65 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 10 Sep 2023 22:02:32 +0200 Subject: [javascript] implement the api call to fetch information about all ships --- nodejs/lib/ships.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'nodejs') diff --git a/nodejs/lib/ships.js b/nodejs/lib/ships.js index d75d78e..eb59013 100644 --- a/nodejs/lib/ships.js +++ b/nodejs/lib/ships.js @@ -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) { -- cgit v1.2.3