In my code, I am trying to fetch data from two JSON files and return them as an array. I did the solution below but it didn't work. What should I do to log those arrays on to the console and achieve what I want?
TS:
requests = [
'data/products.json',
'data/categories.json',
];
constructor(private _http: HttpClient) {
const x = Promise.all(this.requests.map((url) => fetch(url))).then(
async (res) => Promise.all(res.map(async (data) => await data.json()))
);
console.log(x);
}