user19263124
user19263124

Reputation:

Why Am I getting this error 'You need to enable javascript' in my React.js app?

I am getting the you need to enable javascript to run this app error in my MERN stack application. Everything else works fine except for an api call I made for a particular route. I use axios package and all API calls I made in the application are working fine and fetching required data and displayed on my browser. The problem is this particular route. This same route works fine in postman. Here is the code:

useEffect(()=>{
const fetchMenu = async () =>{
   try{
         const response = await axiosPrivate.get(`/api/v1/menu`, { withCredentials: true,headers:{authorization: `Bearer ${auth}`}
                });

        console.log(response.data, 'hello menu')
   }catch(err){

   }
}
fetchMenu()
}, [])

If I call the API via postman, it is fetching the data fine. AxiosPrivate is coming from axios and has been working fine in all places I used it. I really don't know what could be the problem.

Upvotes: 2

Views: 13167

Answers (1)

user19263124
user19263124

Reputation:

The problem was with how I was calling my api. The address should have been /v1/menu instead of /api/v1/menu. This is because in my package.json file already has the proxy this way "proxy": "http://localhost:5000/api/v1",

Upvotes: 2

Related Questions