HarmonyOS RCP数据请求post一个from表单如何实现

HarmonyOS
2024-12-25 17:45:48
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

参考官方文档

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/remote-communication-rcp-V5#section1188301010515

let headers: rcp.RequestHeaders = {
  "accept": "application/json"
};
let configuration: rcp.Configuration = {
  transfer: {
    timeout: { connectMs: 60000, transferMs: 60000 }
  }
};
let cookies: rcp.RequestCookies = { 'name1': 'value1', 'name2': 'value2' };
let transferRange: rcp.TransferRange = { from: 100, to: 200 };

const simpleForm = new rcp.Form({
  "key1": "value1",
  "key2": ["valueList0", "valueList1"],
})

let req = new rcp.Request("http://example.com", "POST", headers, simpleForm, cookies, transferRange, configuration);
req.content = simpleForm;
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
分享
微博
QQ
微信
回复
2024-12-25 19:12:39
相关问题
HarmonyOS RCP POST表单提交咨询
748浏览 • 1回复 待解决
HarmonyOS RCP GET请求POST请求如何传参
1054浏览 • 1回复 待解决
rcp模块能力发起post请求
2234浏览 • 1回复 待解决
HarmonyOS 如何取消一个HTTP请求
691浏览 • 1回复 待解决
HarmonyOS POST请求,服务端拿不到数据
1550浏览 • 1回复 待解决
HarmonyOS rcp网络请求返回数据为null
991浏览 • 1回复 待解决
HarmonyOS 推荐一个http请求
840浏览 • 1回复 待解决
HarmonyOS rcp请求如何传递参数
827浏览 • 1回复 待解决
HarmonyOS POST请求传参
1055浏览 • 1回复 待解决
HarmonyOS rcp请求问题
890浏览 • 1回复 待解决