question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

received status code 204 (no content)

See original GitHub issue

I am using Apollo client with react in the front end running on port 3001. In the back end I am running node/express on port 3000.

In the front end, I have a nav bar that is supposed to run a query and get the user data. When I look at the chrome devtools / network I see something like this:

screen shot 2017-03-24 at 12 11 22 pm

I am not sure why there is a fetch & json at the same time and why the fetch is coming back with response of 204 (empty content). Shouldn’t I only get a fetch with 200 and no json request.

Here is my config in the front end:

const networkInterface = createNetworkInterface({
  uri: '//localhost:3000/graphql'   // pointing to the backend server at port 3000
});

networkInterface.use([{
  applyMiddleware(req, next) {
    if (!req.options.headers) {
      req.options.headers = {};  // Create the header object if needed.
    }
    // get the authentication token from local storage if it exists
    const token = localStorage.getItem('token');
    req.options.headers.authorization = token ? `Bearer ${token}` : '';
    next();
  }
}]);

const client = new ApolloClient({
	dataIdFromObject: o => o.id,
	networkInterface
});

const reducers = combineReducers({
	apollo: client.reducer()
});

const store = createStore(
  reducers,
  composeWithDevTools(applyMiddleware(client.middleware()))
);

Here is my code for the navbar:

const query = gql`
	query {
		user {
			id
			email
		}
	}
`;
export default connect(null, actions)(graphql(query)(NavBar));

And here are snippets code at the backend server:

app.use('/graphql', expressGraphQL({
	schema,
	graphiql: true
}));

Here is the queryType in the backend. I am returning an object just for testing. I tried to wrap the object with Promise but I get the same result.

const RootQueryType = new GraphQLObjectType({
	name: 'RootQueryType',
	fields: {
		user: {
			 type: UserType,
			 resolve(parentValue, args, req) {
				 return {id: "234324", email: "test@test.com"}; 
			 }
		}
	}
});

When I try the query in graphiql, things seems to work fine.

screen shot 2017-03-24 at 12 33 19 pm

Could you please help me figure this out. Thanks

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
imsarveshcommented, Jun 7, 2018

I am also facing same issue. Getting data from graphiql editor but getting 204 (no content) from apollo client 2.0

0reactions
Kruti2502commented, Dec 23, 2022

Facing the same issue, Anyone found any solution ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP Status 204 (No Content)
HTTP Status 204 (No Content) indicates that the server has successfully fulfilled the request and that there is no content to send in...
Read more >
HTTP Get with 204 No Content: Is that normal
204 No Content ... The server has fulfilled the request but does not need to return an entity-body, and might want to return...
Read more >
204 No Content - HTTP status code explained
HTTP response status code 204 No Content indicates that a HTTP request has been completed successfully, and any information being returned is in ......
Read more >
204 No Content - HTTP Status Code Glossary
HTTP Status Code 204: The server has successfully fulfilled the request and that there is no additional content to send in the response...
Read more >
Empty list, HTTP status code 200 vs 204 vs 404
The 204 (No Content) status code indicates that the server has successfully fulfilled the request and that there is no additional content to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found