I have this object, i want to fecth all url.
Object {
"Info": "/api/2",
"Logo": "/api/2/Logo",
"Photo": "/api/2/photo",
}
I want to store the response in a state, like in the example below, I can't know the keys of the object, but no matter what key is the response is organized with that key
Data
[
"Info":
['API RESULTS'],
"Logo":
['API RESULTS'],
"Photo":
['API RESULTS']
]
I made the promise like this
await Promise.all(Object.values(RequestURL).map(Url =>
{
fetch(`${this.state.URL}${Url}`)
.then(Res => Res.json())
.then(Res => this.setState({Data: [...this.state.Data, Res.Data] }))
.catch(Err => this.setState({ IsLoading: false, IsError: true}))
}))
but I don't have the result in the format I want because I only store the data in an array, not an object with the key-value
this.setState({Data: [...this.state.Data, Res.Data] }))
the response I got is
Array [
Array [
Object {
"API_DATA"
}
and i want something like this
Array [
Info: [
Object {
"API_DATA"
}
Logo: [
Object {
"API_DATA"
}