Hello everyone, I need help. I have tried everything I knew but it simply won’t work. After the request has been send, the action is not dispatching anything to the reducer. It works if I try to return payload and type before sending request but I need the data to be loaded. Please help, I need to finish this urgently. Thanks! (I didn’t paste original url and number)
export const sendCode = async (phone) => {
console.log("Telefon" + String(phone))
let formatedPhone = parseInt(phone.substring(1))
formatedPhone = formatPhoneNumber(String(formatedPhone), true)
let success
await axios.post("MY_URL", { "phoneNumber": "123456789" }).then(response => {
console.log(response)
success = true
}).catch(err => {
console.log(err)
success = false
})
return success ? { payload: { msg: "Success", tel: formatedPhone }, type: types.CODE_SENT } : { payload: { msg: "Fail", tel: "" }, type: types.CODE_NOT_SENT }
}