after creating the axios instance code, the post,put, is set and the common request header application/x-www-form-urlencoded;charset=UTF-8. is set. The request using post carries a custom-set request header, but after using put, the request does not carry the set request header. And there is a cross-domain problem. The
code is as follows:
const instance = axios.create({
baseURL: process.env.BASE_API,
timeout: 5000,
withCredentials: true,
headers: {
"content-type": "application/x-www-form-urlencoded;charset=UTF-8"
}
})
function put (url, putData) {
return instance.put(url, qs.stringify(putData))
}
function post (url, postData) {
return instance.post(url, qs.stringify(postData))
}
export default {
get: get,
post: post,
put: put
}
request for post
put