Closed eashish93 closed 7 years ago
@eashish93 Are you using webpack
in your project?
The issue is the entry point defined in package.json
. I'll be publishing a new release today which should fix this issue. I'm working with the master
branch of the library locally in a Vue.js store (with webpack configuration).
Yes, I'm using official create-react-app which comes with webpack. Also, there's another problem in the sdk doesn't have a method for querying things like products?page[limit]=10
.
@eashish93 We're still working to bring all API functionality to the SDK.
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');
}
}
@eashish93 Filtering, sorting and pagination will be separate methods which can be chained. For example:
Moltin.Products.Sort('name').Limit(10).Offset(20).All();
I've read the code. There's no such method in any files in master branch currently.
We're still working to bring all API functionality to the SDK.
@eashish93 As I said above ☝️ 🙃
@eashish93 Are you able to import the library now via the master branch? I'll go ahead and close this issue.
yes, but not as given in the doc. It should be:
import {moltin} from 'moltin';
const Moltin = moltin.gateway({
client_id: 'xxxx'
});
@eashish93 How is your project setup? Are you using Webpack?
I'm using facebook create-react-app which include webpack.
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 ;)
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
It because I think you've not provided any
index.js
file insrc
folder.The only way to make it work using dist folder:
Please add the
index.js
file in src folder.