In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use Ajax's wrapper library Axios". In daily operation, I believe many people have doubts about how to use Ajax's wrapper library Axios. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to use Ajax's wrapper library Axios". Next, please follow the editor to study!
Axios is the most widely used AJAX wrapper library.
The features of Axios are:
Create a XMLHttpRequests from a browser
Create a http request from node.js
Support for Promise API
Intercept requests and responses
Convert request data and response data
Cancel the request
Automatic conversion of JSON data
Client supports defense against XSRF
When using axios, you need to introduce:
Axios Chinese website link: Axios Chinese website
Axios API
Pass the relevant configuration to axios () to create the request
Axios (configuration option for object format)
Axios (url,config)
Commonly used configuration items
Url: the server URL for the request
Method: the method used to create the request
BaseURL: passes the relative URL prefix, which is automatically added before the url
Headers: custom request headers to be sent
Params: the URL parameter to be sent with the request
Data: the data sent as the body of the request
Timeout: specifies the number of milliseconds for request timeout (0 indicates no timeout)
ResponseType: indicates the data type of the server response. The default is "json".
Axios (). Then (function (response) {
/ / response information object response for normal request
})
. Catch (function (error) {
/ / captured error
})
The code is shown as follows:
Configuration of global default values for axios
Axios interceptor: intercepts requests or responses before they are processed by then or catch
Request interceptor for axios
Axios response interceptor
Fast request method of axios
Axios.get (url [, config])
Axios.post (url [, data [, config]])
Axios.delete (url [, config])
Axios.put (url [, data [, config]])
XMLHttpRequest2.0,html5 fully upgrades the XMLHttpRequest type to make it easier to use and more powerful.
Onload / onprogress
XML.onload event: triggered only when the request is completed
XML.onprogress event: triggered only while the request is in progress
Response attribute
The response body is represented as an object, and its type depends on the value of responseType. Request data through a specific type based on the value of responseType.
The responseType setting will not be valid until the request is initialized by calling open () and before the request is sent to the server by calling send ().
At this point, the study on "how to use Axios, the wrapper library of Ajax" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.