fetch('/static/data/data.json')
.then(data => {
console.log(data);
})
But no data was returned to me. Where is the data?
迷茫2017-06-26 10:52:50
First of all, Fetch API is a Web API and has nothing to do with ES7.
Regarding the Fetch API, it needs to cooperate with Request and Response. Here is a more detailed tutorial on how these APIs cooperate to complete the request.
女神的闺蜜爱上我2017-06-26 10:52:50
See MDN:
https://developer.mozilla.org... To make a fetch request
you should use:
data.blob()
欧阳克2017-06-26 10:52:50
fetch('/static/data/data.json')
.then(data =>data.json())
.then(json=>console.log(json))