第八章 网络请求8.1 网络请求概述鸿蒙应用中的网络请求主要使用fetch API或@ohos.net.http模块进行网络通信。网络请求用于:获取远程数据上传数据到服务器与物联网平台通信调用第三方API8.2 HTTP请求8.2.1 使用fetch API// 发送GET请求fetch(‘https://api.example.com/data’).then(response = response.json()).then(data = {console.log(‘获取到数据:’, data)}).catch(error = {console.error(‘请求失败:’, error)})// 发送POST请求fetch(‘https://api.example.com/data’, {method: ‘POST’,headers: {‘Content-Type’: ‘application/json’},body: JSON.stringify({ temperature: 25.5, humidity: 60 })}).then(response = response.json()).then(data = {console.log(‘请求成功:’, data)}).catch(error = {cons