当前位置:网站首页>qs. In the stringify interface, the input parameter is converted into a & connected string (with the application / x-www-form-urlencoded request header)
qs. In the stringify interface, the input parameter is converted into a & connected string (with the application / x-www-form-urlencoded request header)
2022-04-23 07:04:00 【NOyesNONO_】
Basic format
import request from '@/utils/request';// It mainly does some unified encapsulation processing for requests , The use of axios
import qs from 'qs';
export function xxxapi(data) {
return request({
url: 'xxx/xxx/xxx',
headers: {
'content-type': 'application/x-www-form-urlencoded' },
method: 'post',
data: qs.stringify(data)
})
}
Network display
Format of request header and response header
Submit load
The request payload is submitted as a form , With & The string of the connection
After the browser compiles and formats :
Interface to return json Format
The input parameter contains complex data types , Be careful Json Convert to string , Otherwise, the report will be wrong
When qs.stringify Encountered complex data types , Set objects as many as possible :
{
aaa:[{
name:'test',
age:20
}]
}
Displayed in the request as :
At this time, the interface will report an error (500), Because the interface that submits the form should have received variables aaa
, But after treatment, it becomes aaa[0][name]
, Cannot match interface correctly . So when you encounter complex data types , First pass through JSON.stringify()
Convert to string .
other
If only application/x-www-form-urlencoded no need qs.stringify Handle data The input parameter format is as follows :
With application/json Format request
detailed application/json and application/x-www-form-urlencoded difference
版权声明
本文为[NOyesNONO_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230601164949.html
边栏推荐
猜你喜欢
随机推荐
MySQL server standalone deployment manual
js 格式化当前时间 日期推算
异常记录-22
Redis 详解(基础+数据类型+事务+持久化+发布订阅+主从复制+哨兵+缓存穿透、击穿、雪崩)
tensorflow下载
关于Postgres主从复制延迟监控的错误告警问题
DDOS攻击/防御介绍
Virtio and Vhost_ Net introduction
【MySQL基础篇】启动选项、系统变量、状态变量
ansible模块之include_tasks:为什么加了tags后导入的任务没有执行?
异常记录-20
Alertmanager重复/缺失告警现象探究及两个关键参数group_wait和group_interval的释义
异常记录-6
rdma网络介绍
rdma 介绍
将博客搬至CSDN
如何通过dba_hist_active_sess_history分析数据库历史性能问题
异常记录-12
Kubernetes CoreDNS常见问题资料参考
数据库基本概念:OLTP/OLAP/HTAP、RPO/RTO、MPP