I am trying to fetch a get route from a nodejs api that returns some json data. How ever when I try to make a request to that route, I get this message in my browser console :Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
Here is the nodejs api code:
app.get('/vusers',(req,res)=>{
console.log("got a request")
return res.json({"message":"hello"})
})
Here is the reactjs code that makes the request:
useEffect(()=>{
fetch('/vusers',{
headers:{
'Accept': 'application/json'
}
})
.then(res=>res.json())
.then(result=>{
console.log(result)
})
},[])