I am using an API URL that has different data depend on the page URL, but I want to get all the pages URLs in one call, but not getting any data, except when I try to get only one page. Please can someone please help me out?
Here is my code:
function arrayFetcher(urlArr) {
const fetcher = (url) => axios.get(url).then((res) => res.json());
return Promise.all(urlArr.map(fetcher));
}
let urlArray = [];
for(let i = 0; i < 20; i++) {
urlArray.push(`https://api.google.com/page=250&page=${i}&sparkline=false`);
}
const { data } = useSWR(urlArray, arrayFetcher);
{data && console.log(data)}