Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR -> "Cannot read property 'get' of undefined" when using post with auth headers #24

Closed
mmswi opened this issue May 9, 2018 · 7 comments

Comments

@mmswi
Copy link

mmswi commented May 9, 2018

Hello all,

Any ideas why I'm getting this error?

My utils file here: https://github.com/mmswi/graphQL-tut/blob/master/src/utils.js
My mutation here: https://github.com/mmswi/graphQL-tut/blob/master/src/resolvers/Mutation.js
Note, I've hardcoded the user id and used a try catch block, as I got an error in the console that was saying:
(node:16656) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

Anyways, same "Cannot read property 'get' of undefined" error received when not using a try catch block.

With the hardcoded id, the post function works, so I'm wondering why is the context get returning that error. The auth headers have been added also in the graphql playground
{ "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjamd5ODg1MXczZGd3MGIwOG91dHE1OWRrIiwiaWF0IjoxNTI1ODkyMjQwfQ.mW-uDhlG3cGJRi14lw2g_YQSVLWS1Xnkw_VzK_QliO0" }

Thanks

@sapkra
Copy link

sapkra commented Dec 3, 2018

I'm getting the same error with subscriptions. Have you found a fix for it?

@mmswi
Copy link
Author

mmswi commented Dec 3, 2018

Unfortunately, no. But also, I don't use graphql in my job or projects.

@sapkra
Copy link

sapkra commented Dec 3, 2018

Ok but thanks for you quick answer.

@itscarlosrufo
Copy link
Contributor

Thanks @mmswi for opening this issue 😄. It seems to be solved following the latest docs. Closing this for now, please, feel free to open an issue if you cannot make it work!

@brittneypostma
Copy link

Having the same issue going through the How To GraphQL backend graphql-node tutorial. Here is the repo hackernews-node. Getting error Cannot read property 'get' of undefined from the src/utils.js file.

@sdhmdh
Copy link

sdhmdh commented Oct 11, 2020

Hi @brittneypostma , did you get the solution?

@ISProjectsIoTCR
Copy link

Mismo error, alguna solución? Estoy usando strapi v4 y al hacer una mutation aparece: Error: GraphQL error: Cannot read property 'get' of undefined
GraphQL error: Cannot read property 'get' of undefined

Ayuda por favor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants