功能场景描述及使用场景本模块提供HTTP数据请求功能。应用程序可通过HTTP发起数据请求。常见的HTTP方法包括GET、POST、HEAD、PUT、DELETE、PATCH、OPTIONS。使用模块功能实现GET请求发送使用的核心API@rcp.Session.Get核心代码解释Http_GetRcp() { const session = rcp.createSession(); session.get("https://www.baidu.com").then((response) => { console.log("test---------" + response.toString()); AlertDialog.show( { title: 'request接口回调结果', message: '请求网站:' + '百度' + '\n\n' + 'Callback Data: ' + response.toString(), }) }).catch((err:BusinessError)=> { AlertDialog.show( { title: 'request接口回调结果', message: '请求失败,错误信息:' + err.data, }) console.error("test err:" + JSON.stringify(err)); }); }注明适配的版本信息IDE版本:4.1.3.500SDK版本:HarmonyOS Next Developer Preview 1
功能场景描述及使用场景
本模块提供HTTP数据请求功能。应用程序可通过HTTP发起数据请求。常见的HTTP方法包括GET、POST、HEAD、PUT、DELETE、PATCH、OPTIONS。
使用模块功能实现GET请求发送
使用的核心API
@rcp.Session.Get
核心代码解释
注明适配的版本信息
IDE版本:4.1.3.500
SDK版本:HarmonyOS Next Developer Preview 1