I just started using redux, and I'm trying to fetch some data from Firebase and put it in my store. I did some research into the matter and it looked like to me that this:
export const addData = (database) => {
return dispatch => database.ref.once('value').then((snapshot) => {
dispatch({
type: 'STORE_DATA',
payload: snapshot.val()
});
}, (err) => {
dispatch(
{type: 'STORE_FAILED'})
})
}
should work, however I am getting an error "Error: Actions must be plain objects. Use custom middleware for async actions" when I call
store.dispatch(addData(firebase.database()))
I'm not sure what I'm doing wrong.