question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't import moltin using es6

See original GitHub issue

Hi, I can’t be able to import moltin in react using es6. I got the following error: Uncaught TypeError: (0 , _moltin.gateway) is not a function

 // this doesn't work
import {gateway as MoltinGateway} from 'moltin'; 

It because I think you’ve not provided any index.js file in src folder.

The only way to make it work using dist folder:

// It worked
import {gateway as MoltinGateway} from 'moltin/dist/moltin.cjs.js';

Please add the index.js file in src folder.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
eashish93commented, May 2, 2017

Currently I’m also using master branch with slight modifications to support querying like this:

export default class Collections {
    constructor(config) {
        this.config = config;
        this.request = new Request(config);
    }

    Tree(qs) { 
      // where qs  is a string with things like: `page[limit]=10`.
        return this.request.send(`collections?${qs}`, 'GET');
    }

}

0reactions
nclsmitchellcommented, May 6, 2017

Hi @eashish93 ,

I encountered the same problem as you, I fixed it by using the following:

import {gateway as MoltinGateway} from 'moltin'

and then:

const Moltin = MoltinGateway({
    client_id: 'XXXX',
})

The syntax client_id is the key 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import router from file with ES6 import/export?
I am converting my whole node app to use the ES6 syntax import NME from "./file". In my app.js file I am trying...
Read more >
Can't import npm package using es6 module #233 - GitHub
Hi, sorry for a stupid question, but I just can't seem to import the Cookies object in my project no matter what I...
Read more >
How to use an ES6 import in Node.js? - GeeksforGeeks
Introduction to ES6 import: The import statement is used to import modules that are exported by some other module. A module is a...
Read more >
export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >
How to use ES6 import syntax in Node.js - DEV Community ‍ ‍
The solution to this error is in the first line of the above error snippet and is now a recommend way by Node.js....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found