From 241086eda5505312154cd9a0cd7e7672dd71c512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Prokein?= Date: Wed, 22 Dec 2021 08:24:58 +0100 Subject: [PATCH] Updated datasets endpoint data structure. --- src/client.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/client.ts b/src/client.ts index 98ac793..14a4e84 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,6 +1,7 @@ import fetch from "isomorphic-unfetch"; import qs from "querystringify"; import { + IDataset, IDatasetListResponse, IDatasetMetadataResponse, IStockOverlayFetchResponse, @@ -104,8 +105,10 @@ export class Client { /* Miscellaneous API -------------------------------------------------------------------------*/ - public async getDatasetList(): Promise { - return this.requestData(Paths.datasets); + public async getDatasetList(): Promise { + return this.requestData(Paths.datasets).then((data) => { + return data.datasets; + }); } public async getDatasetMetadata(datasetId: string): Promise { @@ -116,7 +119,7 @@ export class Client { return this.requestData(Paths.datasetMetadata(datasetId.trim())); } - public async getTickerDatasetList(ticker: string): Promise { + public async getTickerDatasetList(ticker: string): Promise { if (!ticker || ticker.trim().length === 0) { return Promise.reject(new Error("Missing or invalid ticker")); } @@ -124,7 +127,11 @@ export class Client { const params = { ticker: ticker.trim(), }; - return this.requestData(Paths.datasets + qs.stringify(params, "?")); + return this.requestData(Paths.datasets + qs.stringify(params, "?")).then( + (data) => { + return data.datasets; + }, + ); } public async getTickerList(query: string, datasetId?: string) {