Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chen0040/js-magento-client
Magento javascript client for node.js
https://github.com/chen0040/js-magento-client
es6 js magento-client magento2
Last synced: 6 days ago
JSON representation
Magento javascript client for node.js
- Host: GitHub
- URL: https://github.com/chen0040/js-magento-client
- Owner: chen0040
- License: mit
- Created: 2017-09-09T01:24:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-07T23:36:47.000Z (about 7 years ago)
- Last Synced: 2024-11-23T01:41:36.007Z (30 days ago)
- Topics: es6, js, magento-client, magento2
- Language: JavaScript
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# js-magento-client
Magento javascript client for node.js using ES6 class
# install
```bash
npm install js-magento-client
```# Usage
### Login Api
```javascript
import {MagentoAccountApi} from 'js-magento-client';
import expect from 'expect';let url = 'magento-url';
let username = 'username';
let password = 'password';MagentoAccountApi.loginAsClient(
url,
username,
password)
.then((response) => {
let token = response.data;
expect(response.status).toEqual(200);
expect(token.length).toBeGreaterThan(0);
done();
}).catch(reason => {
console.log(reason);
done(new Error(reason));
});
```### Root Category Api
```javascript
import {MagentoCategoryApi} from 'js-magento-client';
import expect from 'expect';let url = 'magento-url';
MagentoCategoryApi.loadRootCategory(url).then(response => {
let rootCategory = response.data;
expect(rootCategory.children_data.length).toBeGreaterThan(0);
done();
}).catch(reason => {
console.log(reason);
done(new Error(reason));
});
```### Load Products in a particular category
```javascript
import {MagentoCategoryApi} from 'js-magento-client';
import expect from 'expect';let categoryId = 19;
let url = 'magento-url';MagentoCategoryApi.loadProducts(url, categoryId).then(response => {
//console.log(response.data);
expect(response.data.length).toBeGreaterThan(0);
done();
}).catch(reason => {
console.log(reason);
done(new Error(reason));
})
```### Load Product by SKU
```javascript
import {MagentoProductApi} from 'js-magento-client';
import expect from 'expect';let sku = 'product_dynamic_17';
let url = 'magento-url';MagentoProductApi.loadProduct(url, sku).then(response => {
let product = response.data;
console.log(product);
done();
}).catch(reason => {
console.log(reason);
done(new Error(reason));
});
```