Question - Will this work with Async Fetch on Nuxt?
See original GitHub issueHi,
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:
- Created 3 years ago
- Comments:13 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
"generate": "nuxt generate",
with"generate": "nuxt build && nuxt export",
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