1. 申请网络权限
在module.json文件中添加
"module": { "reqPermissions": [ {"name": "ohos.permission.INTERNET"} ] }
2. 发起
// 导入http模块 import http from '@ohos.net.http'; //创建http 实例 const httpRequest = http.createHttp(); // 发起请求 let url = "" let _request = httpRequest.request(url, { method: http.RequestMethod.GET, //POST 请求请求参数 extarDate: { "param1": "value1", "param2": "value2" } , header: { 'Content-Type': 'application/json' } })
最后promise拿到结果
标签:httpRequest,http,请求,鸿蒙,module,json,HTTP From: https://www.cnblogs.com/allenxieyusheng/p/17917325.html