Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.....
Action file:
import $ from 'jquery'
import { phoneVerify } from '../actions/types'
const verifyPhoneAsync = function (verification) {
return {
type: phoneVerify,
payload: verification
}
}
const verifyPhone = function (phone) {
$.ajax({
url: 'api',
type: 'POST',
data: { mobile: phone },
dataType: 'json',
success: (data) => {
console.log(data)
}
})
}
const verifyOtp = function (phone, otp) {
return (dispatch) => {
$.ajax({
url: 'api',
type: 'POST',
data: { mobile: phone, code: otp, devicetoken: 'nil', devicetype: 'nil' },
dataType: 'json',
success: (data) => {
if (data.success === true) {
localStorage.setItem('MobileNumber', phone)
const varification = data
dispatch(verifyPhoneAsync(varification))
} else {
console.log('rfg')
const varification = data
dispatch(verifyPhoneAsync(varification))
}
}
})
}
}
export { verifyPhone, verifyOtp }