- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 3.2k
 
Async Functions with Babel
        imed jaberi edited this page Jul 15, 2020 
        ·
        1 revision
      
    To use async functions in Koa in versions of node < 7.6, we recommend using babel's require hook.
require('babel-register');
// require the rest of the app that needs to be transpiled after the hook
const app = require('./app');To parse and transpile async functions,
you should at a minimum have the transform-async-to-generator
or transform-async-to-module-method plugins.
For example, in your .babelrc file, you should have:
{
  "plugins": ["transform-async-to-generator"]
}You can also use the env preset with a target option "node": "current" instead.