CTX undefined
See original GitHub issueTrying to use your example with apollo-boost while setting an authorization header, but contect ctx always seems to be undefined?
How do I require context while still using your HOC?
// apollo.js
import withApollo from 'next-with-apollo';
import ApolloClient from 'apollo-boost';
import getConfig from 'next/config';
import { getCookieJwt } from './auth';
const { publicRuntimeConfig } = getConfig();
export default withApollo(
({ ctx, headers }) => {
return new ApolloClient({
uri: `${publicRuntimeConfig.SERVER_URL}/api`,
request: async operation => {
const token = await getCookieJwt(ctx); //ctx is undefined
operation.setContext({
headers: {
authorization: token ? `Bearer ${token}` : ''
}
});
}
});
},
);
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
TypeError: "ctx.cart is undefined" - Stack Overflow
Now issue here is that I'm not able to bind the data on cart.component.html side with 'cart', it generates this error- ERROR TypeError:...
Read more >JSLink - javascript error: "ctx is undefined" - MSDN
The ctx object is a render context object that is created by the SPClientTemplates class defined in clienttemplates.js file. From what I've been ......
Read more >Uncaught TypeError: this.ctx is undefined · Issue #2334 - GitHub
Describe the bug. Implement toast editor integration under the framework of wordpress's Block Editor, use the React Editor wrapper, ...
Read more >Await undefined • REPL • Svelte
... noop, safe_not_equal, set_data, space, text } from "svelte/internal"; function create_catch_block(ctx) { let t_value = /*error*/ ctx[2] + ""; let t; ...
Read more >Class ctx.page | SAP Help Portal
appli, {ctx.application}, parent application, undefined. comment, {string}, page comment, undefined. component, {Object}, optional technical component ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Honestly, I feel like something more explicit would be better than inferring whether browser or not like this.
It has added the ctx - so yes looks like it addressed the problem. I do now have a new warning in the console below - though its unclear how this should be related to this fix, so ill continue to investigate. Posting here in case it makes sense to you (I don’t get this error using the next example implementation)
index.js:1 Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer’s output format.
Update: this seems reported elsewhere (#60 ) - will review that discussion.
Thankyou for addressing this so quickly all looks good.