fetch('/static/data/data.json') .then(data => { console.log(data); })
Aber die Daten wurden mir nicht zurückgegeben.
Following the voice in heart.
首先 Fetch API 是一个 Web API,跟 ES7 没什么关系。
关于 Fetch API,需要配合 Request 和 Response 两个,关于这些 API 如何配合完成请求,这里有比较详细的教程。
参见MDN:https://developer.mozilla.org...进行_fetch_请求应该使用:
data.blob()
fetch('/static/data/data.json')
.then(data =>data.json()) .then(json=>console.log(json))
首先 Fetch API 是一个 Web API,跟 ES7 没什么关系。
关于 Fetch API,需要配合 Request 和 Response 两个,关于这些 API 如何配合完成请求,这里有比较详细的教程。
参见MDN:
https://developer.mozilla.org...进行_fetch_请求
应该使用:
fetch('/static/data/data.json')