How to write in Async/Await style?

#32 · closed · 2 comments

View on GitHub ↗

anonimusprogramus

Hi Luke, here's an example. ```javascript function fetchPromise() { httpie.get('someApi').then(res => console.log(res.data)) } async function fetchAsync() { const res = await httpie.get('someApi') console.log(res.data) } let router = navaid() router.on('/', () => fetchPromise()) router.listen() ``` `fetchPromise()` works, but `fetchAsync()` failed. Thank you.

Comments

anonimusprogramus

I just found the issue, it's babel-related. Here's [the solution](https://github.com/babel/babel/issues/8829#issuecomment-456524916) that worked for me. I'm closing this issue. Thanks.

lukeed

Ah, great! Glad you uncovered it. Was going to say – those are semantically equivalent, it's just a difference in syntax