jeudi 15 février 2018

Unable to process response from fetch api

I'm making a get request to an API through window.fetch but I'm getting an error while I am trying to process the response into JSON.

window.fetch(`https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=${result}`, {
  method : 'get',
  mode: 'no-cors',
  headers: {
    'Accept': 'application/json'
  }
})
.then(function(response){
    response.json()
    .then(function(data){
      console.log(data);
    })
    .catch(function(err){
      console.log(err);
    })
})




Aucun commentaire:

Enregistrer un commentaire