axios如何定义返回数据类型?

2年前 (2022) 程序员胖胖胖虎阿
186 0 0
axios.post('/api/user').then((res)=>{
  if(res.code === 0){
    // 成功
  }
})

但是res这里类型提示会告诉我有data/config/headers,就是没有code。

我已经在拦截器中做了处理

axios.interceptors.response.use((response) => {
  return response.data;
}, (error) => {
  return Promise.reject(error);
});

请问我真实的接口返回的数据结构类似{code,data,msg}这种的数据结构,在哪里定义呢?

版权声明:程序员胖胖胖虎阿 发表于 2022年10月24日 下午7:32。
转载请注明:axios如何定义返回数据类型? | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...