a get request to the address https://api.steampowered.com/ISteamApps/GetAppList/v2/?format=json is sent too long with this code:
https.get("https://api.steampowered.com/ISteamApps/GetAppList/v2/?format=json", (res) =>
{
res.setEncoding("utf8");
let bodyCount = "";
res.on("data", (dataCount) => {
bodyCount += dataCount;
});
res.on("end", () => {
bodyCount = JSON.parse(bodyCount);
console.log(bodyCount);
});
});
The process takes up to several seconds, so how to make it happen faster?
In case anyone is wondering how I solved the problem:
setInterval(() =>{
https.get("https://api.steampowered.com/ISteamApps/GetAppList/v2/?format=json", (res) => {
res.setEncoding("utf8");
let body ="";
res.on("data", (dataCount) => {
body += dataCount;
});
res.on("end", () =>{
fs.writeFile('./steamdatabase.txt', body, (err) => {
if (err) {
console.error(err)
return
}
});
});
});
}, 86400000);
...
fs.readFile('./steamdatabase.txt', (err, data) => {
if (err) {
console.error(err)
return
}
let body = JSON.parse(data);
for(let i = 0;i<body.applist.apps.length;i++){
if(body.applist.apps[i].name == generateParameter(args)) appidGame = body.applist.apps[i].appid;
}
if(appidGame) appInfo(appidGame,mess);
});