Why the Axios request interface will initiate two requests

Source: Internet
Author: User

Before using Axios to find each call interface will have two requests, the first request when the option request, and do not see the request parameters, then did not notice, only as a pre-request, to determine whether the interface is smooth, but the recent discovery is not so.

First we know the option request when an extra request is made, so what does this do?

If it is just an ordinary Ajax request, the request will not be initiated and will be initiated automatically only if the AJAX request binds to the upload event and crosses the domain. See HTTP://WWW.TUICOOL.COM/ARTICLES/3UBZIBB in detail.

It is clear that we have upload event bindings (which are usually local debugging, so there will be cross-domain), I looked at the next Axios document, found that the config configuration file has two parameters

// onuploadprogress:function (progressevent) {    //      //Do whatever your want with the native Progress event    // },//  ondownloadprogress:function (progressevent) {////Do     Whatever want with the native Progress event//  },

The upload and download events are handled separately, that is, the upload event is bound here, so there is an option request for each request.

The solution is simple, just comment out, of course, if the development of the project on-line with the requested interface is the same domain name will naturally not two requests. Look at personal needs, about the use of Axios on a Boven introduction http://www.cnblogs.com/Upton/p/6180512.html

Why the Axios request interface will initiate two requests

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.