未处理的拒绝(SyntaxError):意外的令牌<在位置0的JSON中

时间:2018-02-15 00:05:25

标签: javascript html css reactjs web

我在react.js编码,我真的不知道发生了什么。我使用unirest来进行api调用,但是fetch不起作用,所以我觉得我在fetch语句中做错了。

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]

    });
  })

0 个答案:

没有答案