如何在JavaScript ES6中使用异步和等待

时间:2019-05-04 18:34:02

标签: javascript django reactjs webpack babel

我已经使用react并学习了新概念(异步并等待),并且在项目中使用django作为后端,并使用Webpack和Babel作为前端进行了反应。

这是我组件中的方法

async loadProducts(){
        const response = await fetch(this.endpoint, {
            method: "GET",
            headers: {
                "Content-Type": "application/json"
            }
        });
        return await response.json();
}

并引发一些错误(Uncaught ReferenceError: regeneratorRuntime is not defined

0 个答案:

没有答案