This is a npm module for implementing authorization and authentication in any project.
- You can install the package by using the following command :
npm install github:amanaryan29/gate-keeper#master --save
-
This module require 3 configuration data to proceed:
- API Url (
baseURL) - Login Url (
loginURL) - Cookie Name (
cookieName)
- API Url (
-
Import the module to your
api.jsfile. eg:Import ApiWrapper from gate-keeper -
Create an object which can have all the three configuration data. eg:
const config = { baseURL: '', loginURL: '', cookieName: '' } -
Create an Instance of ApiWrapper class and pass the config to it. eg:
const apiwrapper = new ApiWrapper(config) -
ApiWrapper will create an axios instance internally as
apiClientand you can use it for api request. eg:api = apiwrapper.apiClient -
Export
apito make it available throughout the project. eg:export { api }