strapi icon indicating copy to clipboard operation
strapi copied to clipboard

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

Open lustremedia opened this issue 4 years ago • 0 comments

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?

lustremedia avatar May 24 '21 19:05 lustremedia