HarmonyOS ohos_axios库的post请求设置content-type为x-www-form-urlencoded,导致请求失败

ohos_axios库的post请求设置content-type为x-www-form-urlencoded,导致请求失败。charles抓不到请求,应该是组件内部构件请求过程就出错了。

HarmonyOS
2025-01-10 08:50:41
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

报错为Parameter error.The type of 591 must be string,文档中描述如下:

// data是作为请求主体被发送的数据
// 只适用于这些请求方法PUT,POST和PATCH
// 在没有设置transformRequest时,必须是以下类型之一,其他类型使用transformRequest转换处理
// - string, plain object, ArrayBuffer
data: {
  firstName: 'Fred'
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

data的数据不能是number,使用的id数据类型是number,需要修改为string。

分享
微博
QQ
微信
回复
2025-01-10 12:01:24


相关问题
http请求中能否不设置Content-Type参数
2616浏览 • 1回复 待解决
基于@ohos/axios网络请求能力
1059浏览 • 1回复 待解决
2.1.1版本axiospost请求会报401
1470浏览 • 1回复 待解决
HarmonyOS POST请求传参
707浏览 • 1回复 待解决
HarmonyOS axios请求问题
460浏览 • 1回复 待解决
HarmonyOS RCP GET请求POST请求如何传参
680浏览 • 1回复 待解决