106
rated 0 times
[
107]
[
1]
/ answers: 1 / hits: 7145
/ 5 Years ago, wed, december 18, 2019, 12:00:00
In fact, I begin with node.js. And i don't know how to pass the response to a variable. I don't want to make my code in my response.. I try a lot of things but nothing is working.. I know is a simple question.. but it's not working
const axios = require('axios');
var test = null
function getLeagues () {
axios.get('https://api-football-v1.p.rapidapi.com/v2/fixtures/league/525?timezone=Europe/Paris', {
headers: {
'X-RapidAPI-Key': '<my-api-key>'
}
})
.then(response => {
test = response.data.api.fixtures
return response.data.api.fixtures
})
.catch(error => {
console.log(error);
});
}
console.log(test)
More From » node.js