Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught (in promise) Error: Request failed with status code 404

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

like image 282
Ishan Patel Avatar asked Mar 08 '23 05:03

Ishan Patel


1 Answers

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'

like image 169
neelesh bisht Avatar answered Mar 25 '23 02:03

neelesh bisht