rcp模块能力发起post请求

rcp模块能力发起post请求

HarmonyOS
2024-05-28 20:40:54
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
是潘达不是胖达

本模块提供HTTP数据请求功能。应用程序可通过HTTP发起数据请求。常见的HTTP方法包括GET、POST、HEAD、PUT、DELETE、PATCH、OPTIONS。

使用模块功能实现POST请求发送

使用的核心API

@rcp.Session.Post

核心代码解释

Http_PostRcp() { 
  const session = rcp.createSession(); 
  const content: rcp.RequestContent = { 
    "name":"张三" 
  } 
  session.post("https://www.baidu.com", content).then((response) => { 
    console.log("xcy---------" + response.toString()); 
    AlertDialog.show( 
      { 
        title: 'request接口回调结果', 
        message: '请求网站:' + '百度' + '\n\n' + 'Callback Data: ' + response.toString(), 
      }) 
  }).catch((err:BusinessError)=> { 
    AlertDialog.show( 
      { 
        title: 'request接口回调结果', 
        message: '请求失败,错误信息:', 
      }) 
    console.error("xcy err:"); 
  }); 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.

注明适配的版本信息

IDE版本:4.1.3.500

SDK版本:HarmonyOS Next Developer Preview 1

分享
微博
QQ
微信
回复
2024-05-29 21:44:31
相关问题
使用rcp模块能力发送Get请求
2066浏览 • 1回复 待解决
HarmonyOS RCP GET请求POST请求如何传参
1063浏览 • 1回复 待解决
RCP发起请求时如何设置超时时间
1302浏览 • 1回复 待解决
HarmonyOS RCP POST表单提交咨询
751浏览 • 1回复 待解决
HarmonyOS rcp能力调用demo
732浏览 • 1回复 待解决
HarmonyOS POST请求传参
1077浏览 • 1回复 待解决
HarmonyOS rcp请求问题
897浏览 • 1回复 待解决
HarmonyOS rcp模块使用例子
595浏览 • 1回复 待解决
鸿蒙rcp.post为什么返回Precondition Failed
588浏览 • 1回复 待解决
HarmonyOS rcp取消网络请求
1044浏览 • 1回复 待解决
HarmonyOS http 请求 post 参数问题
2412浏览 • 1回复 待解决
没有专类Post请求接口公共请求
3546浏览 • 1回复 待解决
HarmonyOS 网络发起多个并发请求
916浏览 • 1回复 待解决
求告知如何发起HTTP请求
1297浏览 • 1回复 待解决
HarmonyOS rcp网络请求报错1007900994
996浏览 • 1回复 待解决