4***@qq.com
4***@qq.com
  • 发布:2023-12-12 15:21
  • 更新:2023-12-15 15:26
  • 阅读:241

uni-app是否支持fetch请求,app端调用第三方接口POST必选先fetch一下token,不支持怎么办

分类:uni-app
2023-12-12 15:21 负责人:无 分享
已邀请:
喜欢技术的前端

喜欢技术的前端 - QQ---445849201

是要请求三方的接口,在请求头里加token吗?

  • 4***@qq.com (作者)

    嗯嗯对的。第三方接口,post的时候需要类似于 像fetch请求一下token

    2023-12-13 14:33

  • 喜欢技术的前端

    回复 4***@qq.com: uni.request 或者 axios 也是可以在请求接口的时候给请求头添加token ,如果你这个token 是 通过接口请求来的,可以通过async await 利用Promise 进行同步请求 拿到token,在调正式的接口

    2023-12-13 15:45

  • 4***@qq.com (作者)

    回复 喜欢技术的前端: "message": "There is no suitable adapter to dispatch the request since :\n- adapter xhr is not supported by the environment\n- adapter http is not available in the build",

    "name": "AxiosError",

    "stack": "AxiosError: There is no suitable adapter to dispatch the request since :\n- adapter xhr is not supported by the environment\n- adapter http is not available in the build\n at Object.getAdapter (app-service.js:5830:13)\n at Axios.dispatchRequest (app-service.js:4705:35)\n at Axios.request (app-service.js:1939:44)\n at Axios.httpMethod [as post] (app-service.js:1975:19)\n at Function.wrap [as post] (app-service.js:1794:15)\n at _callee$ (webpack-internal:///12:59:39)\n at tryCatch (app-service.js:563:17)\n at Generator.<anonymous> (app-service.js:644:22)\n at Generator.next (app-service.js:588:21)\n at asyncGeneratorStep (app-service.js:841:24)",

    "code": "ERR_NOT_SUPPORT",

    "status": null 试了的 报这种错误

    2023-12-15 15:18

4***@qq.com

4***@qq.com (作者)

xhr is not supported by the environment

要回复问题请先登录注册