[Vuejs]-VueJS / ExpressJS (Backend) – Getting data from an API

0πŸ‘

In your express code you do not return the repsonse (which you also override in the axios response). Try changing it to

app.get('/summoner', function(request, res) { // <--- careful here is a change
  axios.get('https://euw1.api.riotgames.com/lol/summoner/v3/summoners/by-name/XXXXXXXX', {headers: headers})
  .then(response => {
    console.log(response.data)
    return res.status(200).send(response.data);
  })
  .catch(error => {
    console.log(error)
    return res.status(400).send(error);
  })
})

0πŸ‘

I actually resolved this by doing:

res.json([response.data])

In the ExpressJS side of things.

I also had to use response.data[0] within Vue.

Leave a comment