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

Getting undefined from GraphQL #4

Open
peirix opened this issue Mar 19, 2020 · 2 comments
Open

Getting undefined from GraphQL #4

peirix opened this issue Mar 19, 2020 · 2 comments

Comments

@peirix
Copy link

peirix commented Mar 19, 2020

I tried setting this up, but for some reason all the requests come back with an undefined response. I rewrote the plugin to inject the function into the context so I could use it synchronously, and then it worked just fine.

inject('nuxtSeomaticMeta', (fullPath, id) => {
  //same code
});

So I'm wondering if there's something in the context of when the plugin is running? I've also logged out the actual query that's running, and putting that into a GraphQL client also returns the seomatic data.

@peirix
Copy link
Author

peirix commented Mar 20, 2020

Just thought I'd update on this, as I found a working solution:

head() {
    return this.seomatic;
},
mounted() {
    this.$root.context.app.seomaticMeta('/', 1).then(res => {
        this.seomatic = res;
    });
}

Not sure why this works, but using asyncData doesn't.

@ben-rogerson
Copy link
Owner

that's interesting, I wonder if there's been a change in nuxt lately.
I'll take a look into it.

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

2 participants