axios-digest
is axios add digest auth.
npm install --save axios-digest
See test code. (index.test.ts
)
It pretty much is a wrapper around Axios. the primary or most commonly-used HTTP methods only are available -> POST, PUT, PATCH, GET, DELETE, HEAD
. See below for usage upfront (It was inspired from the test file).
AxiosDigest Constructor AxiosDigest(username: string, passwd: string, customAxios: AxiosInstance|AxiosStatic)
username
: Not optional |string
.password
: Not optional |string
.customAxios
: Optional. An existing axios instance |AxiosInstance|AxiosStatic
.
import AxiosDigest from '.';
const username = '[username]';
const passwd = '[pass]';
const base = 'http://localhost';
const axiosDigest = new AxiosDigest(username, passwd);
// Go ahead and make them request!
Interface for setting the username && password beyond the constructor
. It does not include a custom Axios instance as in the constructor.
It receives an object and the fields username
&& passwd
are not Optional, and returns the same, only that the value for field passwd
is masked.
axiosDigest.info = {username, passwd};
const info = axiosDigest.info; // { username: '[username]', passwd: '***' }
The HTTP Methods available have been previously highlighted and returns a Promise.
path
: Not optional |string
.data
: Optional |any
.config
: Optional |AxiosRequestConfig
.
Makes a HEAD
request.
axiosDigest.head(path: string, config?: AxiosRequestConfig): Promise<any>;
Makes a DELETE
request.
axiosDigest.delete(path: string, config?: AxiosRequestConfig): Promise<any>;
Makes a GET
request.
axiosDigest.get(path: string, config?: AxiosRequestConfig): Promise<any>;
Makes a PATCH
request.
axiosDigest.get(path: string, data: any, config?: AxiosRequestConfig): Promise<any>;
Makes a PUT
request.
axiosDigest.put(path: string, data: any, config?: AxiosRequestConfig): Promise<any>;
Makes a POST
request.
axiosDigest.post(path: string, data: any, config?: AxiosRequestConfig): Promise<any>;
MIT