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.

Question - Will this work with Async Fetch on Nuxt?

See original GitHub issue

Hi,

Thank you for this package.

Could you please confirm will this work on async fetch on nuxt components(not page)? As I do not want to query firestore after generating the pages.

I have my async fetch call in one of the component like this.

  async fetch() {
    const response = this.$fireStore.collection('recipes').limit(10)
    try {
      await response.get().then((querySnapshot) => {
               querySnapshot.forEach((doc) => { this.articles.push({  ...doc.data()       })
        })      })    } catch (e) {
      console.log('There is some error: ' + e)
    }  }

my Nuxt generate dynamic route as below.

 generate: {
    minify: false,
    async routes() {
      const { StoreDB } = require('./services/fireinit')
      const qs = await StoreDB.collection('recipes')
        .where('publish', '==', true)
        .orderBy('updated', 'desc')
        .limit(10)
        .get()
      return qs.docs.map((x) => `/${x.data().slug}`)
    }
  }

Your help is much appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
DreaMindercommented, May 18, 2020
  1. replace in package.json "generate": "nuxt generate", with "generate": "nuxt build && nuxt export",
  2. add to nuxt.config:
target: 'static',
ssr: true,
0reactions
rajesh-hcommented, May 27, 2020

Thank you very much for all the assistance. This will make calls to my api which I do not want in this case. Anyway no issues, I will see what can be done. I see some new module nuxt/content. I will try with that.

You have been very helpful

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Fetching - Nuxt
In Nuxt we have 2 ways of getting data from an API. We can use the fetch method or the asyncData method. Nuxt...
Read more >
Nuxt Content async fetch in component - vue.js - Stack Overflow
So, there is no reason that $content will not work in components, I double-checked. It's just the way fetch works in comparison to...
Read more >
Understanding when to use async fetch, mounted and data ...
I'm trying to get a better understanding of the lifecycle of a Nuxt app that is statically generated and could use some help....
Read more >
Universal data fetching in Nuxt.js | by Fotis Adamakis - Medium
If you want to fetch data on the server without blocking navigation during client-side rendering then use Fetch. (If you are using Nuxt...
Read more >
How to use promises - Learn web development | MDN
With a promise-based API, the asynchronous function starts the operation and returns a Promise object. You can then attach handlers to this ...
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