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:
The pictures are purely handwritten, if there are any mistakes in the code words, please forgive me~