N
Nuxt7mo ago
FoxCode

How to make only one request when website build

I created plugin like this: https://github.com/nuxt/nuxt.com/blob/main/plugins/stats.ts but i get [error] [nitro] [unhandledRejection] [GET] "https://api.github.com/repos/xyz": 429 too many requests xtimes on yarn generate. I changed $fetch('https://api.nuxt.com/stats') to
Promise.all([$fetch("https://api.github.com/repos/xyz"), $fetch("https://api.github.com/repos/xyz")]).then((data) => {
data.forEach((el) => {
ghStars.value += el?.stargazers_count || 0
})
})
Promise.all([$fetch("https://api.github.com/repos/xyz"), $fetch("https://api.github.com/repos/xyz")]).then((data) => {
data.forEach((el) => {
ghStars.value += el?.stargazers_count || 0
})
})
GitHub
nuxt.com/plugins/stats.ts at main · nuxt/nuxt.com
The Nuxt website, made with Nuxt. Contribute to nuxt/nuxt.com development by creating an account on GitHub.
2 Replies
FoxCode
FoxCodeOP7mo ago
Yeah, I know about rate limit, but I want to make only one request, but nuxt plugin on generate runs each time while prerendering each page individually, I just want to get the data once and save it to a variable and then use it in navigation as a static variable on static website
Want results from more Discord servers?
Add your server