0.3.0 • Published 2 years ago

axios-digest v0.3.0

Weekly downloads
187
License
MIT
Repository
github
Last release
2 years ago

axios-digest

Build Status

axios-digest is axios add digest auth.

Installation

npm install --save axios-digest

Usage

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)

Parameters

  • 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!

Fields && Methods

axiosDigest.info

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: '***' }

axiosDigestHTTP_METHODS

The HTTP Methods available have been previously highlighted and returns a Promise.

Similar Parameters

  • path: Not optional | string.
  • data: Optional | any.
  • config: Optional | AxiosRequestConfig.

axiosDigest.head

Makes a HEAD request.

axiosDigest.head(path: string, config?: AxiosRequestConfig): Promise<any>;

axiosDigest.delete

Makes a DELETE request.

axiosDigest.delete(path: string, config?: AxiosRequestConfig): Promise<any>;

axiosDigest.get

Makes a GET request.

axiosDigest.get(path: string, config?: AxiosRequestConfig): Promise<any>;

axiosDigest.patch

Makes a PATCH request.

axiosDigest.get(path: string, data: any, config?: AxiosRequestConfig): Promise<any>;

axiosDigest.put

Makes a PUT request.

axiosDigest.put(path: string, data: any, config?: AxiosRequestConfig): Promise<any>;

axiosDigest.post

Makes a POST request.

axiosDigest.post(path: string, data: any, config?: AxiosRequestConfig): Promise<any>;

License

MIT