question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

help: How to use 'this.$nuxt.refresh()'

See original GitHub issue

📚 What are you trying to do? Please describe. A clear and concise description of your objective. Ex. I’m not sure how to […]. composition-api how use this.$nuxt.refresh() https://nuxtjs.org/docs/2.x/internals-glossary/$nuxt#refreshing-page-data

🔍 What have you tried? Have you looked through the docs? Tried different approaches? The more detail the better. The related document was not found

ℹ️ Additional context Add any other context or information. Is there a missing description ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mathe42commented, Feb 12, 2021

You can get $nuxt with:

defineComponent({
   setup(props, ctx) {
     ctx.root.$nuxt
   }
})

0reactions
cluyuncommented, Feb 12, 2021

First log looks good. In the others you should log context.root.$nuxt and context.root.$nuxt.refresh this should result in not undefined values

No problem code:

import { defineComponent } from "@nuxtjs/composition-api";

function getMsg() {
  if (Math.random() >= 0.5) {
    return "1111";
  }
  return "222";
}

export default defineComponent({
  asyncData: function () {
    return { msg: getMsg() };
  },
  setup: function (props: any, context: any) {

    function refresh() {
      context.root.$nuxt.refresh();
      console.log(context.root);
      console.log(context.root.$nuxt);
      console.log(context.root.$nuxt.refresh);
    }


    return { refresh };
  },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

$nuxt: The Nuxt helper
Refreshing page data. refresh(). When you want to only refresh the data provided by asyncData or fetch. example.vue <template> <div> <div>{{ content }} ......
Read more >
How can I refresh the whole page on link visit in NuxtJS?
If you want to refresh the page manually you can call - this.$router.app.refresh().
Read more >
this. nuxt refresh Code Example - Code Grepper
To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Read more >
refreshNuxtData · Nuxt Utils
Refresh All data. This example below refreshes all data being fetched using useAsyncData and useFetch on the current page. pages/some-page.vue
Read more >
[Nuxt 3] How the data fetching ( and refreshing ) is supposed ...
e.g. when using useAsyncData, the first parameter is "key" that controls the cache: const { data } = await useAsyncData('count', () => $fetch('/ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found