HarmonyOS 有没有封装好的axios网络请求库,不太会用axios网络请求

有没有封装好的axios网络请求库,不太会用axios网络请求,post请求传参每次都需要先定义一个接口吗?

HarmonyOS
2024-12-28 07:29:46
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
fox280

axios的三方库链接供参考:https://ohpm.openharmony.cn/#/cn/detail/@ohos%2Faxios,另外post请求传参不需要每次都定义一个接口,提供一个demo参考:

axios.post('xxxx', { data: {
  'ag':18,
  'name':'tom'
}} as AxiosRequestConfig)
  .then((res: AxiosResponse) => {
    console.log('-----------')
  })
  .catch((error: AxiosError) => {
    console.log('err:'+JSON.stringify(error.response))
  })
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
分享
微博
QQ
微信
回复
2024-12-28 10:39:20


相关问题
有没有异步封装好一些网络请求
714浏览 • 1回复 待解决
基于@ohos/axios网络请求能力
1385浏览 • 1回复 待解决
HarmonyOS axios请求问题
810浏览 • 1回复 待解决
HarmonyOS http网络请求封装Demo
874浏览 • 1回复 待解决
有没有基于socket封装成熟网络
1551浏览 • 1回复 待解决
HarmonyOS axios接口请求
883浏览 • 1回复 待解决
有没有带拦截器网络可以封装
1082浏览 • 1回复 待解决