apollo
apollo copied to clipboard
value is null
Environment
- Operating System: Windows_NT
- Node Version: v18.12.1
- Nuxt Version: 3.6.2
- Nitro Version: 2.5.2
- Package Manager: [email protected]
- Builder: vite
- User Config: devtools, css, components, srcDir, modules, postcss, apollo, alias
- Runtime Modules: @nuxtjs/[email protected], @nuxtjs/[email protected], [email protected]
- Build Modules: -
Describe the bug
I have this code
const result = await useAsyncQuery(usersQuery)
const Users = result.data.value?.users
and when i log result I have something in data value but when i log result data value it shows that it is null
Expected behaviour
just give me the result of my query
Reproduction
No response
Additional context
No response
Logs
No response
does anyone else have this error?
does anyone else have this error?
Yes I am, but when I disabled ssr in nuxt.config, the data loaded when the browser reloaded. I think this library does not support ssr yet.
but I need SSR
It loads on the server but when it hydrates it retries the request and then becomes null @Diizzayy ?
Edit: Doesnt work on initial load but works on hot reload
I ran into a similar issue where I had a <client-only> component that was calling useAsyncQuery in its script setup.
Oddly, adding an await nextTick() call fixed the issue.
My queries work fine except for when I have logged in, closed tab and then and navigate directly to a page that has useAsyncQuery in setup. Seems Authentication isn't sent in this case and my backend returns a 401. Bearer token Is stored in Cookie in SSR, and is available when my function is called I can see.
@jumptrnr, do you have proxyCookies set to false in the configuration?
If it is true. probably this PR will fix the issue https://github.com/nuxt-modules/apollo/pull/618
PS: This library does support SSR; we are using it without any problems with SSR enabled.