0.0.5 • Published 6 years ago
qa-api-client v0.0.5
javascript-qa-client
Javascript client library for using the QuestionAnswer Middleware API (https://documenter.getpostman.com/view/958448/RVg56mab).
API
For using that API client library you need to install it as package
npm i -s git+ssh://git@github.com/DigitalGenius/javascript-qa-client.git#develop
Note: your server should contain ssh
key for that module or you can change type of authorization for download it
After that you can import APIClient
module and initialize it with options you need, then share it to your modules for using
api-client.js
import APIClient from 'qa-api-client';
const host = 'some API host';
const authTokenProvider = 'some auth token';
const apiClient = new APIClient(host, authTokenProvider);
export default apiClient;
some-module.js
import APIClient from './api-client.js';
APIClient.auth0.login('some', 'credentials').then(...);
import APIClient from './api-client.js';
// Initialise after creation of client
const host = 'some API host';
const authTokenProvider = 'some auth token';
APIClient.init(host, authTokenProvider);
Options
name | description | is required? | default |
---|---|---|---|
host | string Host of the API which you want to call | true | undefined |
authTokenProvider | string | function For calling some API methods which require an authorization token you should provide that option as string which should be a token (e.g. 'Barear 123asd') or function which should returning a string with token (it's usefull for getting your token from localStorage or whereever you want to store your token). That token will be added as Authorization header value for every API method which need an authorization | true | undefined |
Publishing
For create new production-ready bundle in root of project run command
npm run publish