Bivrost axios adapter
Bivrost Adapter for axios function.
npm i --save axios bivrost-axios-adapter
Usage
With Bivrost:
;;; const api = ; static api = loadAll: ; { return this; }
Direct calls:
; const api = ; const options = method: 'GET' query: groupId: 10 headers: 'Content-Type': 'application/json' ; ;
Adapter options
; const api = ;
Available options:
- transformRequest - allows changes to the request data before it is sent to the server
- transformResponse - allows changes to the response data to be made before
- headers - are custom headers to be sent
- paramsSerializer - is an optional function in charge of serializing
params
- timeout - specifies the number of milliseconds before the request times out
- withCredentials - indicates whether or not cross-site Access-Control requests
- auth - indicates that HTTP Basic auth should be used, and supplies credentials
- responseType - indicates the type of data that the server will respond with
- xsrfCookieName - is the name of the cookie to use as a value for xsrf token
- xsrfHeaderName - is the name of the http header that carries the xsrf token value
More details - https://www.npmjs.com/package/axios#request-api
Interceptors
The main difference between axios-adapter interceptors and axios interceptorsis - is that interceptors could be specified for each adpater separately.
; const api = ;
Interceptor example:
; const api = ;
Bivrost allows to organize a simple interface to asyncronous APIs.