Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug 当这样配置GET请求时,会导致服务响应出错,问号后面参数变成?{}&_=1628253644521 #486

Open
fulicat opened this issue Aug 6, 2021 · 1 comment

Comments

@fulicat
Copy link

fulicat commented Aug 6, 2021

data: setting.async.contentType.indexOf('application/json') > -1 ? JSON.stringify(tmpParam) : tmpParam,

当这样配置时,会导致服务响应出错:

type: 'GET',
contentType: 'application/json; charset=utf-8',

请求变成了这样:
http://ss.dev/api/query?{}&_=1628253644521

问题点:

  1. 空参数对象无需发送,可判断过滤掉;
  2. 非 POST 请求时,对象需要转换成 ?a=1&b=2 这种形式;

修复方法:

- data: setting.async.contentType.indexOf('application/json') > -1 ? JSON.stringify(tmpParam) : tmpParam,
+ data: setting.async.contentType.indexOf('application/json') > -1 ? (setting.async.type.toUpperCase() != 'POST'?$.param(tmpParam) : (Object.keys(tmpParam).length ? JSON.stringify(tmpParam) : '')) : tmpParam,
@fulicat fulicat changed the title bug 当这样配置会导致服务响应出错,问号后面是{} bug 当这样配置会导致服务响应出错,问号后面参数变成?{}&_=1628253644521 Aug 6, 2021
@fulicat fulicat changed the title bug 当这样配置会导致服务响应出错,问号后面参数变成?{}&_=1628253644521 bug 当这样配置GET请求时,会导致服务响应出错,问号后面参数变成?{}&_=1628253644521 Aug 6, 2021
@zTree
Copy link
Owner

zTree commented Aug 17, 2021

感谢,等我抽空去测试更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants