nuxt-modules / nuxt-modules/strapi

Data is not the same when doing a page reload vs $router.push

Open
#141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
717
Forks
89
Avg merge
7h 3m
Merged PRs (30d)
6

Description

Version

@nuxtjs/strapi: ^0.3.1
nuxt: 2.15.3

Steps to reproduce
  1. I have a collection which has a has and belongs to one with $strapi.user named endpoint
  2. I am a calling following method to get some endpoint data while $strapi.user is logged in:
  async asyncData({$strapi}) {
    try {
      if($strapi.user) {
        let getendpoint = null
        console.log($strapi.user.endpoint) // called with route, returns id, page reload returns endpoint object
        getendpoint = await $strapi.find('endpoints', {'id': $strapi.user.endpoint}) // works with page reload, but not with route.push       
        getendpoint = await $strapi.find('endpoints', {'id': $strapi.user.endpoint.id}) // works with $route but not page reload

        if(getendpoint) {
        ...

When routed to the page via this.$nuxt.$router.push('/route') from login I get a different $strapi.user.endpoint object compared to a page refresh $strapi.user.endpoint.

a.) The $router.push redirect returns an int id of the endpoint
b.) The page reload returns an endpoint object and to make the call I need to call $strapi.user.endpoint.id to get the getendpoint

What is Expected?

It should return the same data object on route and page reload

What is actually happening?

It returns different data objects doing the same call to $strapi.user.endpoint with different loading methods ... why?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in asyncData with $strapi.user.endpoint, comparing navigation through $router.push with a full page reload. Check both endpoint and endpoint.id against the reported $strapi.find calls; done means the behavior is explained and the endpoint data is consistent or the discrepancy is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxtjs, typescript
Domain
api, authentication, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.