Next and Pre pagination

Hi!

I have a little problem with this solution:

async asyncData({ $prismic, params, store }) {
        const page = await $prismic.api.getByUID("article", params.uid);
        const { results: articles } = await $prismic.api.query($prismic.predicate.at("document.type", "article"));

        const prevpost = (await $prismic.api.query(
          $prismic.predicates.at("document.type", "article"),
          {
            pageSize : 1 ,
            after : `${article.id}`,
            orderings: '[my.article.date]'
          }
        )).results[0]

        const nextpost = (await $prismic.api.query(
          $prismic.predicates.at("document.type", "article"),
          {
            pageSize : 1 ,
            after : `${article.id}`,
            orderings: '[my.article.date desc]'
          }
        )).results[0]


        return {
            page,
            articles,
            prevpost,
            nextpost
        };
    },

And HTML:

<nuxt-link v-if="prevpost" :to="prevpost.url" class="button">Previous Post</nuxt-link>
<nuxt-link to="/blog" class="button">All posts</nuxt-link>
<nuxt-link v-if="nextpost" :to="nextpost.url" class="button">Next Post</nuxt-link>

I have an error : "article is not defined".

I don't understand what i'm doing wrong.

Hello @Vincent07

I don't find any issue with this query. It looks good to me.

Do you have an article page in your repo? Can you share your repo name with me by private message?

Thanks,
Priyanka