Spring

axios에서 return 사용법 then((res)=> { 가 있는경우

MDanderson 2023. 4. 27. 07:57

return axiosInst.post~~하는순간 res가 가는줄알았는데

then((res)=>{  를 하면 res가 가는게아니고 then으로 들어간다
그래서 받는쪽에서 const res에는 undefined가 들어온다

 

즉 then((res)=> 를 쓰면 그안에서 return 값을 만들어줘야 받는쪽에서 받아서 쓸수있다.