Data interception of Axios


Have you ever encountered data delay in development projects? For example, if you click on a function, there will be a delay of 1-2s. This 1-2s may display an animation in a circle all the time on your page. I wonder if there are any partners who do not know how to realize this function? In fact, this is very common in a project. If you use element, and you are familiar with loading on element, you just need to use it directly. However, if your project requirements do not allow it or you need to implement this function yourself, how can we implement it? Of course, this is only one of the functions, and it can also play a lot of roles. Later, small editors will continue to improve.

1. Interceptor interceptor, whether intercepting in request phase or intercepting in response phase, has two parameters: success function and failure function.

2. Request phase interception

Note: the config must return. If you intercept it, you must do something







3. Interception in response phase






Author: Jin Feifei
Mobile phone number (wechat synchronization): 17812718961
I hope this article can bring harvest to friends who are learning front end or work. If you don’t like it, please don’t spray. If you have suggestions, please give me more suggestions. Thank you!!!