Basic wrapper for Magento 2 API using Axios
npm install magento2-api-wrapper@1.5.1
A basic wrapper for Magento 2 API
npm install magento2-api-wrapper
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.
It provides all same methods as Axios: https://github.com/axios/axios#request-method-aliases (request, get, delete, head, options, post, put, patch)
npm run test