[ad_1]
i have problem with my code, all i need is just to save results from looping api into json file using writeFileSync. Here’s my code:
function processRarity(limit) {
var resultJson = [];
for (var i = limit; i < limit + 100; i++) {
const everything = async () => {
const response = await fetch(
"https://api-v2-mainnet.paras.id/token/asac.near::" + i
);
var json = await response.json();
return json;
};
everything().then((res) => {
console.log(res);
resultJson = res;
});
}
fs.writeFileSync(`${basePath}/results.json`, JSON.stringify(resultJson, null, 2));
}
when i check my json file, all i get is just:
[]
[ad_2]