To save JSON data obtained through a fetch request, you can follow these steps:
let dataArray = [];
fetch('url')
.then(response => response.json())
.then(data => {
// code to store data in arrays
});
data.forEach(item => {
dataArray.push(item);
});
Alternatively, you can use the spread operator to add the data to the array:
dataArray = [...dataArray, ...data];
Asked: 2022-05-09 11:00:00 +0000
Seen: 7 times
Last updated: Mar 19 '22