request请求拦截

    1. uni.addInterceptor('request', {
    2. invoke(args) {
    3. // request 触发前拼接 url
    4. args.url = 'https://www.example.com/'+args.url
    5. },
    6. success(args) {
    7. // 请求成功后,修改code值为1
    8. args.data.code = 1
    9. },
    10. fail(err) {
    11. console.log('interceptor-fail',err)
    12. },
    13. complete(res) {
    14. console.log('interceptor-complete',res)
    15. }
    16. })