I am getting above error while fetching some data from the API. Following is the code of the action creator
where I am trying GET
the data:
import { FETCH_USER } from './types';
import axios from 'axios';
export const fetchUser = () => async dispatch => {
console.log('fetchUser');
const res= await axios.get('/api/current_user');
dispatch({ type: FETCH_USER, payload: res });
};
Also when I am debugging in the code editor, console is giving me below error:
SyntaxError: Unexpected token import
Generally this error comes when the url/location provided inside GET method is not correct. So check the url/location again and correct it.
So most probably there is some mistake here : '/api/current_user'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With