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

Cannot read property 'req' of undefined #179

Closed
MartinMalinda opened this issue Jun 11, 2020 · 5 comments · Fixed by #180
Closed

Cannot read property 'req' of undefined #179

MartinMalinda opened this issue Jun 11, 2020 · 5 comments · Fixed by #180

Comments

@MartinMalinda
Copy link

Seems to happen at setActiveReq(context.ssrContext.req);

"nuxt": "^2.11.0",
"nuxt-composition-api": "^0.9.0",
"@vue/composition-api": "^0.6.1",
"pinia": "0.0.6",

universal mode

@MartinMalinda
Copy link
Author

This issue disappears if I uninstall nuxt-composition-api so I guess this is caused by nuxt-composition-api doing something to the ssrContext

@posva
Copy link
Member

posva commented Jun 11, 2020

Apart from creating a different plugin for nuxt to override the app.context like they do, I can't see a different solution

@danielroe
Copy link
Member

@posva I've now exposed a onGlobalSetup hook that could work for Nuxt users like:

// In a plugin file
import { onGlobalSetup } from 'nuxt-composition-api'
import { setActiveReq } from 'pinia' // if this is exposed

export default () => {
  onGlobalSetup((props, context) => {
    setActiveReq(context.ssrContext.req)
  })
}

Let me know if there is anything else I can do from the nuxt-composition-api end.

@posva
Copy link
Member

posva commented Jun 13, 2020

I haven't looked and probably won't be able to for a while but the solution shouldn't need any extra code from the users 🤔

@danielroe
Copy link
Member

danielroe commented Jun 13, 2020

It was intended for you, not the users... 😄

However, I was mistaken on the cause; it's not one of the packages overwriting the other's setup function. I've submitted a PR.

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

Successfully merging a pull request may close this issue.

3 participants