Answer the question
In order to leave comments, you need to log in
Why GET request doesn't work in browser, but it works in Postman?
I have a react app built NOT through create-react-app but with webpack config. When I make a fetch request to localhost:8000/api/muggers in my React app (the server is already created with node):
fetch("http://localhost:8000/api/muggers", param)
.then(response => response.json())
.then(json => console.log(json))
const param = {
method: 'GET',
mode: 'no-cors',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer: token',
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Credentials" : true
},
};
item.js?2f47:29 Uncaught (in promise) SyntaxError: Unexpected end of input
at eval (item.js?2f47:29)
response.json()
Answer the question
In order to leave comments, you need to log in
Read about cross-domain queries.
If using Express, include middleware cors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question