首页 > 解决方案 > React async and await throwing error 'Uncaught ReferenceError: regeneratorRuntime is not defined'

问题描述

I have this bit of code

async makeRestCall() {
    var api = await PrognApi(this.state.Name);
    console.log(api);
  }

but react is throw this

Uncaught ReferenceError: regeneratorRuntime is not defined

in the console. I know I've used async and await before with React but I can't remember how I think I had to install a library. Any advice would be great. I'm using a js file to hold my jsx. I'm using webpack and babel as well.

标签: reactjsrestasynchronousasync-await

解决方案


原来我需要 Babel-polyfill


推荐阅读