HardWare
HardWare
NNuxt
Created by HardWare on 1/29/2025 in #❓・help
Append data on useFetch on page change instead reload
Hi I would like to keep my data of previewed pages and append new data of the existing cached or stop if no more pages. Should I do separate useState or try it inside useFetch, i do not care about hard reloaded data, galleryData is for infinite gallery variable
const {
data: galleryData,
status: galleryStatus,
error: galleryError
} = await useFetch<{
data: ImageItemSchema[],
next: boolean,
}>('/api/images', {
key: 'gallery-data',
query: { page },
watch: [ page ],
retry: 3,
retryDelay: 3000,
lazy: true,
default() {
return { data: [], next: false }
},
transform(input) {
return {
...input,
fetchedAt: new Date(),
currentPage: page.value,
}
},
getCachedData(key) {
const data = nuxtApp.payload.data[key] || nuxtApp.static.data[key]

if (!data) return

if (data.fetchedAt && new Date().getTime() - data.fetchedAt.getTime() > 1000 * 60 * 60) return // 60 minutes

return data
},
})
const {
data: galleryData,
status: galleryStatus,
error: galleryError
} = await useFetch<{
data: ImageItemSchema[],
next: boolean,
}>('/api/images', {
key: 'gallery-data',
query: { page },
watch: [ page ],
retry: 3,
retryDelay: 3000,
lazy: true,
default() {
return { data: [], next: false }
},
transform(input) {
return {
...input,
fetchedAt: new Date(),
currentPage: page.value,
}
},
getCachedData(key) {
const data = nuxtApp.payload.data[key] || nuxtApp.static.data[key]

if (!data) return

if (data.fetchedAt && new Date().getTime() - data.fetchedAt.getTime() > 1000 * 60 * 60) return // 60 minutes

return data
},
})
7 replies
NNuxt
Created by HardWare on 1/20/2025 in #❓・help
Handling multipart/form-data images on backend api
Hi, I want to get form data of image and send it do Cloudinary how should I approach it?
31 replies
NNuxt
Created by HardWare on 11/27/2024 in #❓・help
$fetch and useFetch proxy request receive strange binary instead proper json+ld object
No description
22 replies
NNuxt
Created by HardWare on 11/14/2024 in #❓・help
Docker nuxt $fetch and useFetch
Hi, why do i have to use different http links for each one? My app have back api in different container so request is sended in $fetch to api.localhost or container name php in useFetch. Why is that? I understand that useFetch is prerender data on ssr but can I make one address for request to not get confused over time. Thanks
11 replies
NNuxt
Created by HardWare on 9/20/2024 in #❓・help
How can I prevent showing form data in URL in NuxtUI submit?
Thanks for help
2 replies
NNuxt
Created by HardWare on 9/17/2024 in #❓・help
Proxy api request in docker
No description
1 replies