Friday, 19 May 2017

How create a module with asynchronous exports in NodeJS with ES6

I want to create a module (install in node_modules) for my projects which call the same API. But when I export my async function I get an error :

index.js Unexpected token (3:21)
You may need an appropriate loader to handle this file type.

Index.js is my module file.

Here's example code:

export default async function({path, method = 'GET', body}, userToken = null, contentType = 'application/json') {
     // some code here ...
}

And in my project I import like this :

import invokeApi from 'my_sdk';



via Maxime Signoret

No comments:

Post a Comment