Giter Club home page Giter Club logo

Comments (2)

2460392754 avatar 2460392754 commented on May 29, 2024

1.插件封装过的请求经过请求拦截器之后会直接发送,不会进行二次处理了,所以需要在拦截器里添加params属性并更新url,就需要自己合并了,tools.js里面有封装好的函数。

2.“但是在返回的数据中的config的url却更新了”,这句话是什么意思,是自动更新url了吗。如果可以的话,能截个图吗

from uniapp-tools.

ccbox avatar ccbox commented on May 29, 2024

#1的问题已经在拦截器里去处理了;

#2的问题是这样的,如果没有用#1中的办法在拦截器中合并新的参数到url中:

  • 请求发起参数:
    Request().get(api.home, {params:{ param_one:"one"}});

  • 然后在请求拦截器中设置了参数:
    config.params.channel = "wx";

  • 接着打印xhr中的config,其中的url因为没有合并,所以请求实际地址是没有这个参数的;
    http://domain.com/api?param_one=one

  • 请求结束后,打印响应拦截器中的config,url中就带上了这个参数了;
    http://domain.com/api?param_one=one&channel=wx

所以数据返回的实际上请求的地址是缺少合并参数的:
http://domain.com/api?param_one=one
但是响应拦截器中的结果和配置参数是不对应的。

from uniapp-tools.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.