I'm trying to fetch multiple API URLs using Promise.all
and I need a little help.
For a single API I'm doing:
const [data, setData] = useState();
fetch('https://api.xyz/someURL')
.then(function(response){
return response.json();
)]
.then(function(myJson){
setData(myJson)
})
Now, with a promise I'm trying to do:
const [data,setData]=useState();
Promise.all([
fetch('https://api.xyz/someUrl'),
fetch('https://api.xyz/someOther'),
]).then((responses)=>{
setData(responses)
})
console.log(data)
The console will return this
(2) [Response, Response]
For some reason it's returning the Response and not the actual data that I want. When I fetch with one URL, I can get the data I want.