javascript - Problems with ES7 fetch to obtain data
typecho
typecho 2017-06-26 10:50:50
0
3
755
fetch('/static/data/data.json')
            .then(data => {
                console.log(data);
            })

But no data was returned to me. Where is the data?

typecho
typecho

Following the voice in heart.

reply all(3)
迷茫

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))
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template