After receiving a response, the data is structured as follows:
{
"0": {
"name": "Novartis AG",
"symbol": "NVS",
"has_intraday": false,
"has_eod": true,
"country": null,
"stock_exchange": {
"name": "New York Stock Exchange",
"acronym": "NYSE",
"mic": "XNYS",
"country": "USA",
"country_code": "US",
"city": "New York",
"website": "www.nyse.com"
},
"stock": {
"open": 84.845,
"high": 85.39,
"low": 84.845,
"last": 85.33,
"close": 84.24,
"volume": 3700,
"date": "2022-01-27T14:40:00+0000",
"symbol": "NVS",
"exchange": "IEXG"
}
},
This response consists of multiple nested objects. I have created an interface that defines the structure, like this:
export interface Stock {
ticker: string;
name?: string;
open?: number;
high?: number;
low?: number;
last?: number;
close?: number;
}
Now, my goal is to transform the singular object observable into an array of Stock type observable in the service call:
getStocks(): Observable<Array<Stock>> {
...
}
I am currently facing challenges in achieving this transformation and would greatly appreciate any assistance!