const axios = require("axios"); async function notSoFast(host, port) { let nbArticles = await axios.get(`http://${host}:${port}/articles`); nbArticles = nbArticles.data.message; const articles = []; if (0 + nbArticles === 0) { return articles; } let res = await axios.get(`http://${host}:${port}/articles/${0}`); articles.push(res.data); for (let i = 1; i < 0 + nbArticles; i++) { const delay = res.headers["x-ratelimit-reset"] * 1000 - Date.now(); if (res.headers["x-ratelimit-remaining"] == 0) { await new Promise((oof) => setTimeout(oof, delay + 26)); } res = await axios.get(`http://${host}:${port}/articles/${i}`); articles.push(res.data); } return articles; } module.exports = { notSoFast, };