emporix-js
v2.0.2
Published
SDK package for Emporix api service ## Features
Downloads
71
Readme
Emporix-js
SDK package for Emporix api service
Features
- methods for authenticating user
- methods for using Emporix services
Usage
Create Config
instance:
import { IClientConfig } from 'emporix-js'
const config: IClientConfig = {
env: 'stage',
token: <JWTToken>,
}
In web brawser in most cases LocalStorageStore
is the best option
import { LocalStorageStore } from 'emporix-js'
const storage = LocalStorageStore()
You can also create a custom Store
instance:
const store: = {
saveConfig: (c: IClientConfig) => {
// save config
},
getConfig: () => {
// get config
},
}
Init EmporixClient
:
import { EmporixClient } from 'emporix-js'
const emporixClient = EmporixClient(config, store)
Example usage:
await emporixClient.categoryService
.fetchCategory(categoryId)
Building and publishing
Build:
yarn build
Publish new version in npm (update version in package.js first)
npm publish
Running examples
Running example static stite
Open example.js
Add an example token to TOKEN
const TOKEN = '<yourJWTtoken>'
In root folder
yarn link
cd example
yarn link example-js
python3 -m http.server
Running example node app
Open index.ts
Add an example token to TOKEN
const TOKEN = '<yourJWTtoken>'
Because the emporix-js
uses Axsios under the hood it (which uses XHRequest) you might need to add XHRequest support
yarn add xhr2
global.XMLHttpRequest = require('xhr2')
In root folder
yarn link
cd example-node
yarn link example-js
yarn
yarn dev