在接口没有问题的情况下(通过postman可以验证)
通常是因为JS请求的数据类型与后端要求不一致,请求类型header处设置
headers: {'Content-Type':'multipart/form-data'}
headers: {'Content-Type':'application/json'}
headers: {'Content-Type':'application/x-www-form-urlencoded'}
选择你需要的方式
本文探讨了JS请求数据类型与后端不一致的问题,常见于使用Postman验证接口正常但JS请求失败的情况。文章提供了几种Content-Type设置解决方案,包括'multipart/form-data'、'application/json'和'application/x-www-form-urlencoded'。
在接口没有问题的情况下(通过postman可以验证)
通常是因为JS请求的数据类型与后端要求不一致,请求类型header处设置
headers: {'Content-Type':'multipart/form-data'}
headers: {'Content-Type':'application/json'}
headers: {'Content-Type':'application/x-www-form-urlencoded'}
选择你需要的方式
3855

被折叠的 条评论
为什么被折叠?