mohammadfeiz

mohammadfeiz/boxit-auth

JavaScript
0
0
No license
Total donated
Undistributed
Share with your subscribers:

Recipients

How the donated funds are distributed

Support the dependencies of mohammadfeiz/boxit-auth

Account's avatar
Declarative routing for React web applications
Account's avatar
OpenID Connect & OAuth2 authentication using react context api as state management
Account's avatar
``` javascript npm i aio-apis ``` ### create apis class instance ``` javascript const MyLoader = () => { return '<div class="my-loading"></div>' } class Mock { Users_Get = (type) => { return [ {name:'name1',id:0}, {name:'name2',id:1}, {name:'name3',id:2} ] } } let props:I_apis_props = { id:'my app', baseUrl:'https://my-dev.com/ap/v1', //this is optional(default loader will work) //you can returns any jsx/html as loader loader:()=><MyLoader/>, //this function will call after request went to catch //in this case you should return an string error message to user onCatch:(err,apiConfig)=>{ if(err.response){ return err.response.message } else if(err.message){ return err.message } else { return 'unknown error' } }, //check all apis and if is error conditions return error message else return undefined //you can check is token valid or not in this function . if not valid you can call logout getError:(response,apiConfig)=>{ if(response.data.isSuccess === false){ return response.data.message } else if(response.status === 401){ logout() } }, //define apis in dictionary apis:{ Users_Get:{ //read User_Get from Mock class instance mockResult:true }, Users_Add:{ //optional //error messages of popups will create from this description //for example description:'adding user', //set api method method:'post', //set api url by baseUrl getUrl:(baseUrl)=>`${baseUrl}/Users/Add`,

Top contributors

mohammadFeiz's profile
mohammadFeiz
3 contributions

Recent events

Kivach works on the Obyte network, and therefore you can track all donations.

No events yet