Axios code: result.data is empty, result has status 200.
const axios = require('axios');
axios.get('https://fantasy.premierleague.com/api/bootstrap-static/')
.then(result => {
console.log(result);
console.log(result.data);
})
.catch (error=>{
console.log(error);
});
https code (returns JSON from API):
const https = require('https');
https.get('https://fantasy.premierleague.com/api/bootstrap-static/', (response)=>{
let data = '';
response.on('data', (chunk) =>{
data += chunk;
});
response.on('end', ()=>{
console.log(data);
})
})
The fantasy API returns JSON only I believe. Can anyone let me know what I need to do to get the axios get request to return the data?
If I use a different API with the axios code, for example (https://api.chucknorris.io/jokes/random) it works fine. It seems to be something different with this API perhaps?