Hi, I'm a newbie to RTK Query and I have a question. I made an API call that returns an array of arrays of objects, and I'd like to leverage the transformResponse option to flatten the API response into a single array of objects.
Below is the code snippet:
getStocks: builder.query({
query: credentials => ({
url: `stocks`,
body: {credentials},
transform: response => {
console.log(response);
return response;
},
}),
})
This is the data structure of the API response:
[
// Arrays of information for different stocks
]
I aim to format the data as follows:
Symbo | Close |
---|---|
AAPL | 120 |
BYD | 130 |
CSC | 123 |
SEC | 433 |