第一次 写axios请求,但是好像发送不到目标服务器,不知道是哪里写错了,希望各位能帮我看看,非常感谢!
//添加axios模块
const axios = require('axios');
const url='http://gdxzzy.g8n.cn/student/course/71839/profiles/29';
axios({
//请求的方法
method:'post',
//请求的地址
url:url,
//请求包 的头部
headers:{
'Host': 'gdxzzy.g8n.cn',
'Connection': 'keep-alive',
'Content-Length':' 999',
'Cache-Control':' max-age=0',
'Upgrade-Insecure-Requests': '1',
'Origin': 'http://gdxzzy.g8n.cn',
'Content-Type': 'xx',
'User-Agent':'xx',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/wxpic,image/tpg,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'X-Requested-With': 'com.tencent.mm',
'Referer': 'http://gdxzzy.g8n.cn/student/course/71839/profiles/29',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
'Cookie': '有三条cookie'
},
timeout: 1000,
//请求包数据
data:{
'form_id': 123,
"formid_": 123,
"formdata[b]": "XXX",
"formdata[a]": 1,
"formdata[c]": 1,
"formdata[d]": 0,
"formdata[f]": 0,
"formdata[g][]": 4,
"formdata[h]": 0,
"formdata[i]": 123,
"formdata[j]": "xxx",
"formdata[k]": 123,
"_bjmf_fields_s": {"gps":["b"]},
"formdata[gps_addr]":"XXX",
"formdata[gps_xy]":"XXX",
"_score": 0
},
}).then(res=>{
console.log(res);
}).catch(error=>{
console.log(error);
console.log('错误');
});