Axios is one of the best javascript HTTP client based on promises. It works on all modern browsers, and has many features:
- Make XMLHttpRequests from the browser,
- Make HTTP requests from node.js,
- Supports the Promise API,
- Intercept request and response,
- Transform request and response data,
- Cancel requests,
- Automatic transforms for JSON data,
- Client side support for protecting against XSRF.
Axios allows you to set custom headers to your ajax requests. It can be done in three ways:
1. In a single http request
2. Global configuration for all requests or separately for POST/GET/DELETE method
a) To set header1 with value = value1 for all POST request use:
b) To set header1 with value = value1 for all requests use:
3. Set for specific axios instance
a) Create single axio instance:
b) Set global headers for specific instance
b) Use interceptor to set headers for requests
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}