6
Describe the issue
"Content-Type": "application/x-www-form-urlencoded"
是 会携带 一个 :
Code snippet to illustrate your question
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<style>
.uploadWrap {
margin: 20px;
}
</style>
</head>
<body>
<div>
<button onclick="axiosPostWithForm()">axios post 提交json格式数据</button>
</div>
</body>
<script>
const BASEURL = "http://localhost:7001/api";
// axios post 提交application/x-www-form-urlencoded格式数据
function axiosPostWithForm() {
axios({
url: BASEURL,
method: "post",
data: {
id: 121,
},
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
}).then(res => {
console.log(`axios request`);
console.log(res.data);
});
}
</script>
</html>
Expected behavior, if applicable
{"id":121}
- Axios Version [e.g. 0.18.0]
- Adapter [e.g. XHR/HTTP]
- Browser [e.g. Chrome, Safari]
- Browser Version [e.g. 22]
- Node.js Version [e.g. 13.0.1]
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]