I call getLocalToken action from my component which reads a string from AsyncStorage . The following is how I call the function.
componentWillMount() {
this.props.getLocalToken();
console.log("CWM", this.props.auth);
}
The following is my Action
export const getLocalToken = async () => {
try {
const localToken = await AsyncStorage.getItem('@auth:localToken');
const mobileNumber = await AsyncStorage.getItem('@auth:mobileNumber');
}
catch (e) {
console.log('Failed to read token', e);
}
return (dispatch) => {
console.log("get token");
dispatch({
type: types.GET_LOCALTOKEN_SUCCESS,
payload: { localToken: this.localToken, mobileNumber: this.mobileNumber }
});
}
}
For this code I get Action must be plain objects. Use custom middleware for async function. error.