axios study notes 2 (source code understanding/simple implementation of axios)

Run the logic:

1. Create axios, including defaults and interceptors properties

2. Set the interceptor and add an object to the interceptors handlers property

3. Call axios , trigger Axios.prototype.request call

    Add the request interceptor handlers property to the front of the chains array

    Add the response interceptor handlers property to the chains array

    Traverse the chains array, handle request interception, and trigger the dispatchRequest function

4. Trigger the xhrAdapte function, send a request, and change the status to padding

   The request is completed, resolve is triggered , continue to traverse the chains array, and handle response interception

5. Trigger axios ().then() or axios ().catch() function

 

demo link:

GitHub - 939624959/miniAxios: axios study notes, simple implementation of axios related functions by imitating source code 

 The pictures are purely handwritten, if there are any mistakes in the code words, please forgive me~

Guess you like

Origin blog.csdn.net/weixin_59128282/article/details/121723084