fetch('/static/data/data.json') .then(data => { console.log(data); })
But no data was returned to me. Where is the data?
Following the voice in heart.
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.
See MDN: https://developer.mozilla.org... To make a fetch request you should use:
data.blob()
fetch('/static/data/data.json')
.then(data =>data.json()) .then(json=>console.log(json))
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.
See MDN:
https://developer.mozilla.org... To make a fetch request
you should use:
fetch('/static/data/data.json')