We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
相关依赖:
"dependencies": { "flyio": "^0.5.4", "mpvue": "^1.0.10", "qs": "^6.5.2", "vuex": "^2.3.1" },
代码:
import Fly from "flyio/dist/npm/wx"; import qs from "qs"; let fly = new Fly; fly.config.baseURL="http://127.0.0.1:8181/"; fly.interceptors.request.use((request, promise)=>{ if (request.method == "POST") { request.headers["Content-Type"] = "application/x-www-form-urlencoded"; // 经测试设置header后已经被库自动编码了 // request.body = qs.stringify(request.body); } return request; }); export function network() { return fly; }
经过测试:
fly会在发送的数据是字符串时将 Content-type设置为application/x-www-form-urlencoded
fly.post('/api/xxx', qs.stringify(data))
application/json;charset=UTF-8
flyio RequestBody默认以json形式传递数据,如果非要以formdata编码传递的话,需要手动编码
The text was updated successfully, but these errors were encountered:
5c7a4f2
请升级到0.5.9重试
Sorry, something went wrong.
上述第三个问题我也遇到了,采用 .request({ method: "get", // post/get 请求方式 url: "", body: {} }) 的方式请求,参数值为汉字的会自动编码,后台还得处理多一次,怎么去掉这个自动编码
.request({ method: "get", // post/get 请求方式 url: "", body: {} })
No branches or pull requests
相关依赖:
代码:
经过测试:
fly会在发送的数据是字符串时将 Content-type设置为application/x-www-form-urlencoded
,但是我在没有设置interceptor时,调用fly.post('/api/xxx', qs.stringify(data))
发现,Content-Type仍然是application/json;charset=UTF-8
。flyio RequestBody默认以json形式传递数据,如果非要以formdata编码传递的话,需要手动编码
,但是经过测试,在interceptor手动设置Content-Type后,hash表数据会被自动urlencode编码,如果使用qs额外编码会导致重复编码(代码中被注释的行)。The text was updated successfully, but these errors were encountered: