# HTTP response code

**URL:** <https://discuss.dgraph.io/t/http-response-code/16278>\
**Category:** App Development\
**Tags:** kind:question, auth, react, apollo-client\
**Created:** [December 9, 2021, 4:04pm UTC](https://discuss.dgraph.io/t/http-response-code/16278 "2021-12-09T16:04:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cueloop](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/cueloop/32/9254_2.png) [@cueloop](https://discuss.dgraph.io/u/cueloop)\
**Post date:** [December 9, 2021, 4:04pm UTC](https://discuss.dgraph.io/t/http-response-code/16278/1 "2021-12-09T16:04:42Z")

</div>

Hi, I am trying to setup Apollo Client in a React web app with Cognito JWT Tokens using Amplify.

So, I noticed I was getting 200 as response code on a GraphQL request with an expired token.  
Is that correct?

This implementation of how to handle an expired token relies on a 401 http response.  
[https://blog.benclmnt.com/blog/apollo-auth/](https://blog.benclmnt.com/blog/apollo-auth/)  
Does anyone here have a good way of handling this?  
Thanks

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [December 9, 2021, 11:26pm UTC](https://discuss.dgraph.io/t/http-response-code/16278/2 "2021-12-09T23:26:12Z")

</div>

Is that a question related to Dgraph’s GraphQL? If not, maybe you can find support at [Dgraph Community (Unofficial)](https://discord.gg/6SXXAmSy).

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [December 9, 2021, 11:39pm UTC](https://discuss.dgraph.io/t/http-response-code/16278/3 "2021-12-09T23:39:42Z")

</div>

I will read that linked post later but in theory GraphQL should always return 200 and can send an error message by official spec.

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [December 9, 2021, 11:49pm UTC](https://discuss.dgraph.io/t/http-response-code/16278/4 "2021-12-09T23:49:12Z")

</div>

Yeah, there are several approaches to error dealing/handling in GraphQL world. There are libs just for it.

---

<div class="post-metadata">

**Author:** ![cueloop](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/cueloop/32/9254_2.png) [@cueloop](https://discuss.dgraph.io/u/cueloop)\
**Post date:** [December 10, 2021, 8:47am UTC](https://discuss.dgraph.io/t/http-response-code/16278/5 "2021-12-10T08:47:14Z")

</div>

Ok thanks! I should have read the spec obviously.

For those interested, I found a working approach with custom fetch. This way the token refreshes before making the api request.

```auto
  const customFetch = async (uri, options) => {

    const session = await Auth.currentSession();

    options.headers.Bearer = session.getAccessToken().getJwtToken();
    return fetch(uri, options);
  };

  const httpLink = createHttpLink({
    uri: config.dgraph_endpoint,
    fetch: customFetch,
  });

```
