I am currently handling parallel requests for multiple fetches and I would like to define results
as an array of response objects instead of just a general array of type any
. However, I am uncertain about how to accomplish this. I attempted to research "how to type response object in Typescript" but unfortunately did not find any helpful results. Is there a way to specify the response object type without manually creating a custom type that encompasses all properties of a response object? Does Typescript offer a specific built-in type that can be utilized in this scenario?
const results: any = [];
fetch(URL, {
headers: {
...
}
})
.then(response => {
results.push(response);
})
.catch(err => {
...
})
const responses = await Promise.all(results);
return responses;