Package Exports
- magento2-api-wrapper
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (magento2-api-wrapper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Magento2 API Wrapper
A basic wrapper for Magento 2 API
Install
npm install magento2-api-wrapper
Usage
const Magento2Api = require('magento2-api-wrapper')
var consumer = new Magento2Api({ api: { url: 'https://localhost' }})
consumer.get('directory/countries')
.then(data => console.log)
// Api Keys: Magento Admin > System > Extensions > Integration
var admin = new Magento2Api({ api: {
url: 'https://localhost',
consumerKey: 'xxx',
consumerSecret: 'xxx',
accessToken: 'xxx',
tokenSecret: 'xxx',
}})
admin.get('products', {
params: {
searchCriteria: {
currentPage: 1,
pageSize: 1,
}
}
})
.then(data => console.log)
Responses: Successfull response returns data as in Magento - not wrapped as in Axios.
Methods / Properties
It provides all same methods as Axios: https://github.com/axios/axios#request-method-aliases (request, get, delete, head, options, post, put, patch)
.axios - get axios instance .baseUrl - get base url
Run tests
npm run test