summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2023-09-10 22:02:32 +0200
committerJulien Dessaux2023-09-10 22:02:32 +0200
commit4551c1a2dd020b6807aca2db90729cd74af9ed65 (patch)
treedfc1406f957021d7fe1a279320c82add19697e67
parent[javascript] add database function to fetch all contracts (diff)
downloadspacetraders-4551c1a2dd020b6807aca2db90729cd74af9ed65.tar.gz
spacetraders-4551c1a2dd020b6807aca2db90729cd74af9ed65.tar.bz2
spacetraders-4551c1a2dd020b6807aca2db90729cd74af9ed65.zip
[javascript] implement the api call to fetch information about all ships
-rw-r--r--nodejs/lib/ships.js10
1 files changed, 9 insertions, 1 deletions
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) {