const handelSubmit = () => {
await userAPI.signIn({
email,password
}).then((res) => {
res.data.isSuccess // 로그인 성공 true of false ???
? (
swalAlert(res.data.message,"",'success',{
buttons: false,
timer: 1000,
}).then(() => {
userAPI.detail(res.data.jwt)
.then((response) => {
if(response.data.isSuccess) SubmitForm(response.data.result[0],res.data.jwt)
}).catch((error) => {
swalAlert(error.message,"", "error", {
buttons: false,
timer: 1000,
})
})
}).catch((err) => {
console.log(err)
})
)
: (
swalAlert(res.data.message,"","error")
)
})
}
이랬던 코드를
const SignIn = async () => {
return userAPI.signIn({
email, password
})
}
const getUserDetail = async (jwt) => {
return userAPI.detail(jwt)
}
const handleSubmit = () => {
SignIn().then((signInRes) => {
signInRes.data.isSuccess
? swalAlert(signInRes.data.message,"","success",{buttons:false,timer:1000}).then(() => {
getUserDetail(signInRes.data.jwt).then((getUserDetailRes) => {
getUserDetailRes.data.isSuccess
? SubmitForm(getUserDetailRes.data.result[0],signInRes.data.jwt)
: null
}).catch((err) => {
swalAlert(err.message,"","error",{buttons:false,timer:1000})
})
})
:swalAlert(signInRes.data.message,'message','error')
})
}
이렇게 바꾸었는데 괜찮은건가 잘 모르겠다....
일단 맥주를 마시며 코드썼으니깐 내일 다시 일어나서 보는거로해보자!!!!