Last active
November 18, 2015 15:17
-
-
Save nqbao/6cb425ce3018ade9239f to your computer and use it in GitHub Desktop.
Babel 6 async error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["es2015", "stage-0"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Abc { | |
async test() { | |
let client; | |
return await this.timeout() | |
} | |
timeout() { | |
return new Promise((resolve, reject) => { | |
setTimeout(resolve, 1000) | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReferenceError: client is not defined | |
at Abc._callee2$ (abc.js:3:15) | |
at tryCatch (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/regenerator/runtime.js:62:40) | |
at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/regenerator/runtime.js:338:22) | |
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/regenerator/runtime.js:95:21) | |
at step (/Users/baonguyen/Projects/sandbox/async-test/abc.js:9:273) | |
at /Users/baonguyen/Projects/sandbox/async-test/abc.js:9:443 | |
at new Promise (/Users/baonguyen/Projects/sandbox/async-test/node_modules/babel-cli/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:197:7) | |
at /Users/baonguyen/Projects/sandbox/async-test/abc.js:9:99 | |
at Abc.test (abc.js:5:32) | |
at _callee$ (main.js:7:15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Abc from './abc.js' | |
let abc = new Abc(); | |
async function main() { | |
try { | |
await abc.test() | |
} | |
catch (ex) { | |
console.log(ex.stack) | |
} | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment