router.get("/fixtures/generate", (_, res) => {
Promise.all([
// EPL BELOW
axios({
"method": "GET",
"url": "https://api-football-v1.p.rapidapi.com/v2/fixtures/league/524/last/10",
"headers": {
"content-type": "application/octet-stream",
"x-rapidapi-host": "api-football-v1.p.rapidapi.com",
"x-rapidapi-key": "6b5ca05e55mshb0e3216e47a54acp1192aajsna0ef871f4f24"
}, "params": {
"timezone": "Europe/London"
}
}),
// LA LIGA BELOW
axios({
"method": "GET",
"url": "https://api-football-v1.p.rapidapi.com/v2/fixtures/league/775/last/10",
"headers": {
"content-type": "application/octet-stream",
"x-rapidapi-host": "api-football-v1.p.rapidapi.com",
"x-rapidapi-key": "6b5ca05e55mshb0e3216e47a54acp1192aajsna0ef871f4f24"
}, "params": {
"timezone": "Europe/London"
}
}),
// CL BELOW
axios({
"method": "GET",
"url": "https://api-football-v1.p.rapidapi.com/v2/fixtures/league/530/last/10",
"headers": {
"content-type": "application/octet-stream",
"x-rapidapi-host": "api-football-v1.p.rapidapi.com",
"x-rapidapi-key": "6b5ca05e55mshb0e3216e47a54acp1192aajsna0ef871f4f24"
}, "params": {
"timezone": "Europe/London"
}
})]
.then((response) => {
fs.writeFile(scoresFilePath, JSON.stringify(response.data.api.fixtures), err => {
if (err) return res.status(409).send("File not saved"); // find right error code
return
console.log("scores saved!");
});
})
.catch(err => res.status(400).send("Could not fetch data"))
)
});
Я использовал квадратные скобки, чтобы поместить все свои вызовы в массив, и получаю ошибку: TypeError: [ax ios (...), ax ios (...), ax ios (...)]. тогда не является функцией в /Users/Desktop/server/routes/routes.js:62:10 в Layer.handle [как handle_request] (/ Users / Desktop / server /node_modules/express/lib/router/layer.js:95:5) в следующем (/Users/one/Desktop/server/node_modules/express/lib/router/route.js:137:13) в Route.dispatch (/Users/one/Desktop/server/node_modules/express/lib/router/route.js:112:3) в Layer.handle [как handle_request] (/ Пользователи // Настольный ПК / сервер / node_modules / экспресс / lib / router / layer. js: 95: 5) в /Users/Desktop/server/node_modules/express/lib/router/index.js:281:22 в Function.process_params (/ Users / Desktop /server/node_modules/express/lib/router/index.js:335:12) на следующем (/Users/Desktop/server/node_modules/express/lib/router/index.js:275:10) в Function.handle (/Users/Desktop/server/node_modules/express/lib/router/index.js:174:3) в маршрутизатор (/Users/Desktop/server/node_modules/express/lib/router/index.js:47:12)
>I am trying to write all the response data into one JSON file with Promise.all