axios post方式請求x-ww格式的數據

       //使用axios時,要肯定是json格式仍是x-www格式的,axios默認是json格式的,若是是x-ww格式須要作以下配置:
        let url = "/hehe/site/getcomment"; let data = { order: 1, pagesize: 10, type: 1, eId: 133535, p: 1 }; const options={ method:"POST", headers:{"content-type":"application/x-www-form-urlencoded"}, data:qs.stringify(data),//須要下載qs依賴,cnpm i qs,node中queryString()有一樣效果
 url, } this.$axios(options).then((data)=>{ console.log(data) }) //vue.config.js中配置跨域代理
module.exports = { devServer: { proxy: { '/hehe': { target: 'https://www.missevan.com', changeOrigin: true, pathRewrite:{ '^/hehe':'' } }, } } }

 

https://www.missevan.com/site/getcomment先在postman中測試接口能不能用:

相關文章
相關標籤/搜索