I'm facing an issue in my code where I am trying to fetch data from two different JSON files and then return them as arrays. Even after implementing the solution below, it doesn't seem to be working as expected. Can someone guide me on how I can successfully log those arrays onto the console?
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);
}