mercredi 14 février 2018

Unhandled Rejection (SyntaxError): Unexpected token < in JSON at position 0

I am coding this in react.js and I really have no idea what is going on. I am using unirest to make the api call but the fetch isn't working so to me it seems I am doing something wrong in the fetch statement.

unirest.get("https://heisenbug-la-liga-live-scores-v1.p.mashape.com/api/laliga/table")
.header("X-Mashape-Key", "Lzrv6ktkq3mshGiQJrPDa9cBxcDGp1Vcdncjsn1DweG4jU5ref")
.header("Accept", "application/json")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});

fetch(unirest)
  .then((response) => {
    return response.json();

  })
  .then((json) => {
    console.log(json)

    this.setState({
      record: json.records[0]

    });
  })



Aucun commentaire:

Enregistrer un commentaire