我在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]
});
})