Accepted answer

The problem is that you are trying to import a default module (which was exported using export default), but you didn't export any default in your file.

So, because your module is not default exported you have to use brackets like this:

import { getAccessToken } from '../helpers/api'   //Here is the import

or export the module as default

export default const getAccessToken = () => {

then you can use it as you do now.

Check the doc: import

And here is something very useful to understand quick about import/exports: [es6] import, export, default cheatsheet


To be more clear, there are two types of exports:

1- Default Exports (One per module)

in your code will be:

export default const getAccessToken = () => {}
import getAccessToken from '../helpers/api' 

2- Named Exports (Zero or more exports per module)

in your code will be:

export const getAccessToken = () => {}
import {getAccessToken} from '../helpers/api' 


This import is for default export,

import getAccessToken from '../helpers/api' 

You have exported as named export, you should import like this,

import {getAccessToken} from '../helpers/api' 

Named Export vs Default Export in ES6

Related Query

More Query from same tag