-
recently there is a requirement to use token for login authentication of WeChat Mini Programs"s users.
-
I pass token to the backend through a custom field in req.header.
so after each AJAX, you need to determine whether a token? is returned in the response.header.
1. If it is not returned, it is not the first time that token has logged in and token has not expired
2. If a token is returned to me, I assign the token to me in a custom field in the request.header.
but I found that there are some AJAX interceptors in Vue or JQ, which can hijack AJAX, globally. If there is no similar interceptor in WeChat Mini Programs, will you have to write a lot of repetitive code?
I hope the seniors who already have some experience will give me some suggestions, thank you! Bow!