怎么使用 axios 设置请求头为 application/x-www-form-urlencoded 格式的?
怎么使用 axios 设置请求头为 application/x-www-form-urlencoded 格式的?
类似这样,多看文档axios
axios({
url: "/yoorUrl", //URL,根据实际情况来
method: "post",
headers: { "Content-Type": "multipart/form-data" },
data: fd
});
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
2 回答4.3k 阅读✓ 已解决
5 回答2.2k 阅读
4 回答4.6k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
4 回答2.1k 阅读✓ 已解决
科普:
application/x-www-form-urlencoded 格式:categoryId=263919&demo=234234
application/json 格式:{"categoryId": 263919}
解决方法:
content-type 会根据请求参数的格式自动变换请求格式。只需要将请求对象转换为 json 格式即可