Simple Crud Service Lib, based on OAuth2 Authorization and Axios Calls
Using npm:
$ npm i -g npm
$ npm i @izzle-org/crud-io
My Crud Service 'product.service.js'
import { CrudService } from '@izzle-org/crud-io'
export default class extends CrudService {
constructor () {
super('products')
}
}
index.js
import { ApiService, JwtService } from '@izzle-org/crud-io'
// Handle OAuth2
...
// JWT Config
JwtService.encrypt = true
JwtService.secretKey = 'foobar123'
JwtService.useSessionStorage()
JwtService.setToken({ access_token: 'foobar' })
// API Config
ApiService.init('https://api.foo.bar')
ApiService.setAuthHeader('Bearer ' + JwtService.getToken().access_token)
import ProductService from './product.service.js'
const service = new ProductService()
// GET https://api.foo.bar/products with Authorization Header (Bearer foobar)
let products = service.list()
Copyright (c) 2020-present Daniel Böhmer