鸿蒙开发使用axios请求后端网络服务出现该错误

{"message":"{"code":201,"message":"Permission denied"}","name":"AxiosError","stack":" at AxiosError (oh_modules/.ohpm/@ohos+axios@2.2.4/oh_modules/@ohos/axios/src/main/ets/components/lib/core/AxiosError.js:22:1)\n at anonymous (oh_modules/.ohpm/@ohos+axios@2.2.4/oh_modules/@ohos/axios/src/main/ets/components/lib/adapters/ohos/http.js:57:1)\n","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["ohos"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{"Blob":null},"headers":{"Accept":"application/json, text/plain, /"},"method":"get","url":"http://192.168.3.55:8080/aa"},"code":201,"status":null}

使用axios请求后端网络服务出现该错误

是没有申请网络权限

在model.json5里面添加一下网络权限就好了

bash 复制代码
"requestPermissions": [
  {
    "name": "ohos.permission.INTERNET"
  }
],
相关推荐
新小梦22 分钟前
DevEco Studio修改HarmonyOS为OpenHarmony
harmonyos
IntMainJhy1 小时前
Flutter 三方库 shimmer 的鸿蒙化适配与实战指南
flutter·华为·harmonyos
IntMainJhy2 小时前
Flutter 三方库 flutter_slidable 的鸿蒙化适配与实战指南
flutter·华为·harmonyos
@不误正业3 小时前
HarmonyOS-6.0-AI全栈能力解析-Data-Augmentation-Kit到智能体开发实战
人工智能·华为·harmonyos·开源鸿蒙
HwJack203 小时前
HarmonyOS APP开发玩透 ArkTS 并发编程
华为·harmonyos
前端不太难4 小时前
鸿蒙 App 架构升级:从页面到 System
架构·状态模式·harmonyos
IntMainJhy4 小时前
Flutter 三方库 image_cropper + flutter_image_compress 的鸿蒙化适配与实战指南
flutter·华为·harmonyos
IntMainJhy5 小时前
Flutter 三方库 flutter_local_notifications 的鸿蒙化适配与实战指南
flutter·华为·harmonyos
李李李勃谦5 小时前
基于鸿蒙PC多窗口特性的笔记管理工具开发实践
笔记·华为·harmonyos