I'm trying to build a react-native app with Redux and I am getting the following error stemming from my Actions file:
Error: Actions must be plain objects. Use custom middleware for async actions
Anyone understand what's going on here? Here is the relevant code:
import axios from 'axios' //http client
import {API_URL} from '../utils/constants'
export const FETCH_USER = 'fetch_user'
export const editProfileUser = async (email, password, name, location, aboutMe, memberSince,
picture) => {
try{
const response = await axios({
method: 'POST',
url: `${API_URL}/api/get_token`,
data: {
email,
password
}
})
const {token} = response.data
const userResponse = await axios({
method: 'POST',
url: `${API_URL}/api/edit_user_profile`,
headers: {
Authorization: `${token}`
},
data: {
name,
location,
aboutMe,
memberSince,
picture
}
})
console.log("userResponse.data", userResponse.data)
return (
{
type: FETCH_USER,
payload: {
token,
email,
password
}
}
)
} catch(err){
console.log("Exception in actions/user/editProfileUser err", err)
}
}