Javascript 异步Axios POST后从服务器检索消息

Javascript 异步Axios POST后从服务器检索消息,javascript,post,async-await,axios,Javascript,Post,Async Await,Axios,调用后如何从服务器检索邮件: 等待axios.post(url、数据) export const postData=async data=>{ 试一试{ 让url=`${api}auth/register`; 让res=等待axios.post(url,data.catch)(e=>console.log(e)); 返回res; }捕获(错误){ console.log(错误); 警惕。警惕(“错误”); } }; 现在,该函数在控制台中返回未定义的。我的动机是从服务器响应获取消息和代码

调用后如何从服务器检索邮件:

等待axios.post(url、数据)
export const postData=async data=>{
试一试{
让url=`${api}auth/register`;
让res=等待axios.post(url,data.catch)(e=>console.log(e));
返回res;
}捕获(错误){
console.log(错误);
警惕。警惕(“错误”);
}
};

现在,该函数在控制台中返回
未定义的
。我的动机是从服务器响应获取消息和代码

  axios.post('url')
  .catch(function (error) {
    if (error.response) {
      console.log(error.response.status);
      console.log(error.response.message);
    }
  });
我知道答案了。