Nuxt 2 asyncData not persisting data on page refresh in production mode, how to solve this issue?

53 views Asked by At

My asyncData does not work correctly in Nuxt 2?

async asyncData ({ store, query }) {
    const type = query.type || "All";
    const search = query.search || "";

    await store.dispatch("demos/fetchData", {
        type,
        search
    });

    return { type, search };
},

It works very well on Development mode, but Production, it does not work.

When I refresh page at URL: localhost:3000/MyPage?type=Spa. This page redirect to: localhost:3000/MyPage/?type=Spa and now the data is data of "All" page not Spa page.

I do not reassign type and search after asyncData

I expect when i refresh the page this data still there.

0

There are 0 answers