jonspe
jonspe
NNuxt
Created by jonspe on 1/12/2025 in #❓・help
nuxi generate only finds 10 from 100 slug routes when paginated to show only 10
Is my approach bad, paginating links? Should I show all links and use CSS to hide the others instead? Anyways, nuxt can't find the other 90 routes. I've tried stuff like this:
async function getBlogRoutes() {
const data = await fetch("https://jsonplaceholder.typicode.com/posts")
const posts = await data.json()
return posts.map((post) => `/blog/${post.id}`)
}
...
generate: {
"nitro.prerender.routes": getBlogRoutes(),
},
async function getBlogRoutes() {
const data = await fetch("https://jsonplaceholder.typicode.com/posts")
const posts = await data.json()
return posts.map((post) => `/blog/${post.id}`)
}
...
generate: {
"nitro.prerender.routes": getBlogRoutes(),
},
but it only still generates the first 10 routes.
6 replies
NNuxt
Created by jonspe on 1/12/2025 in #❓・help
Calling Array.slice() to a fetched array says that slice is not a function
This is what's causing the problem, from what I've understood is that the array is wrapped in a proxy object. I've tried accessing the _rawValue and it worked for a while but it shouldn't be used.
<script setup>
const { data: posts } = useFetch("https://jsonplaceholder.typicode.com/posts")

const postsPerPage = 10
const currentPostIndex = ref(0)

const paginated = computed(() => posts.slice(currentPostIndex.value, currentPostIndex.value + postsPerPage))
...
<script setup>
const { data: posts } = useFetch("https://jsonplaceholder.typicode.com/posts")

const postsPerPage = 10
const currentPostIndex = ref(0)

const paginated = computed(() => posts.slice(currentPostIndex.value, currentPostIndex.value + postsPerPage))
...
This is the error:
Uncaught (in promise) TypeError: posts.slice is not a function
NuxtJS 6
index.vue:7:40
Uncaught (in promise) TypeError: posts.slice is not a function
NuxtJS 6
index.vue:7:40
4 replies