使用axios发送post请求时,如何使用queryParams传递参数

使用axios发送post请求时,如何使用queryParams传递参数

HarmonyOS
2024-07-30 10:46:57
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
人提唱盘

方式1

let params:Url.URLParams = new Url.URLParams()
params.append("fod" : '1')
params.append("bard" : '2')
axios.post('https://developer.mozilla.org/?' + params.toString()).then(res => {
  this.message = "request result: " + JSON.stringify(res.data);
}).catch(err => {
  this.message = "request error: " + err.message;
})

方式2

axios({
  url: 'https://developer.mozilla.org/?',
  method: 'post',
  params: {
    fod: '1',
    bard: '2',
  }
}).then(res => {
  this.message = "request result: " + JSON.stringify(res.data);
}).catch(err => {
  this.message = "request error: " + err.message;
})


分享
微博
QQ
微信
回复
2024-07-30 16:57:57
相关问题
HTTP GET请求如何传递参数
2807浏览 • 1回复 待解决
2.1.1版本的axiospost请求会报401
750浏览 • 1回复 待解决
使用rcp模块能力发送Get请求
639浏览 • 1回复 待解决
关于JS http请求参数传递问题
7071浏览 • 2回复 待解决
使用http发送xml报文格式的请求
1408浏览 • 1回复 待解决
应用在后台发送请求失败问题
130浏览 • 1回复 待解决
rcp模块能力发起post请求
760浏览 • 1回复 待解决
没有专类Post请求接口公共请求
2745浏览 • 1回复 待解决
HarmonyOS关于AXIOS动态传参数问题
71浏览 • 1回复 待解决