sylr
sylr
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
Will do! Thank lucie!
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
if you don't mind I can ask if my cto is comfortable
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
Yeah, unfortunately I know nothing about web developpement and we don't have support anymore from the studio that made the site 😦
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
Ok, thank you very much @Lucie - lihbr
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
does @nuxtjs/sprismic has some sort of caching feature I could use to avoid calling the API every time ?
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
my probes are generated calls to prismic nonetheless
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
but since the calls are made server side
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
I have probes that curl my webistes index though, there are not counted by the analytics because they do not execute javascritp
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
It's not 10x, Prismic tells me I do 7millions calls a month, my analytics tells me my websites has had 382 pageviews for the last 30 days 😭
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
Ok, so for every call I make with curl to my website index, the node process makes 8 calls to prismic server side ...
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
the loop calls are for /api/v2/documents/search
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
I got a response from prismic support
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
/**
* Use in asyncData to handle slices resolving
*/
export async function usePrismicSlicesResolver(slices, prismic) {
try {
if (!slices) return []
return await Promise.all(
slices
.filter((slice) => {
return slice.primary || slice.items
})
.map(async (slice) => {
const component = components[slice.slice_type]
let payload = null
if (component.resolve) {
payload = await component.resolve(slice, prismic)
}

return {
slice,
payload,
}
})
)
} catch (e) {
console.log('--------ERROR PRISMIC SLICES RESOLVER-------', e)
showError({
statusCode: 404,
statusMessage: `Cannot found`,
})
}
}
/**
* Use in asyncData to handle slices resolving
*/
export async function usePrismicSlicesResolver(slices, prismic) {
try {
if (!slices) return []
return await Promise.all(
slices
.filter((slice) => {
return slice.primary || slice.items
})
.map(async (slice) => {
const component = components[slice.slice_type]
let payload = null
if (component.resolve) {
payload = await component.resolve(slice, prismic)
}

return {
slice,
payload,
}
})
)
} catch (e) {
console.log('--------ERROR PRISMIC SLICES RESOLVER-------', e)
showError({
statusCode: 404,
statusMessage: `Cannot found`,
})
}
}
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
export function usePrismicSliceResolver(props, resolve, prismic) {
const resolved = ref()
const loaded = ref(!!props.payload)
try {
if (props.payload) {
resolved.value = props.payload
} else {
onMounted(async () => {
resolved.value = await resolve(props.slice, prismic)
loaded.value = true
})
}
} catch (e) {
console.log('--------ERROR PRISMIC SLICE RESOLVER-------', e)
showError({
statusCode: 404,
statusMessage: `Cannot found`,
})
}

return {
loaded,
resolved,
}
}
export function usePrismicSliceResolver(props, resolve, prismic) {
const resolved = ref()
const loaded = ref(!!props.payload)
try {
if (props.payload) {
resolved.value = props.payload
} else {
onMounted(async () => {
resolved.value = await resolve(props.slice, prismic)
loaded.value = true
})
}
} catch (e) {
console.log('--------ERROR PRISMIC SLICE RESOLVER-------', e)
showError({
statusCode: 404,
statusMessage: `Cannot found`,
})
}

return {
loaded,
resolved,
}
}
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
<template>
<main class="pageSerie pb-48">
<SerieFeaturedCover :document="serie"></SerieFeaturedCover>
<SingleContainer :rows="serie.data.slices.length + 1">
<SingleSidebar>
<AtomDivider class="mt-0 mb-8 mobile background-[#303030]" />
<AtomSidebarEntry
:title="$t('serie.narrated')"
v-if="serie.data.narrator_copyright"
>
{{ serie.data.narrator_copyright }}
</AtomSidebarEntry>
<AtomSidebarEntry
:title="$t('serie.music')"
v-if="serie.data.narrator_copyright"
>
{{ serie.data.music_copyright }}
</AtomSidebarEntry>
<AtomSidebarEntry
:title="$t('serie.editing')"
v-if="serie.data.narrator_copyright"
>
{{ serie.data.editing_copyright }}
</AtomSidebarEntry>

<AtomSidebarEntry
class="mt-16"
:title="$t('serie.watch')"
v-if="
serie.data.youtube_external.url! ||
serie.data.vimeo_external.url ||
serie.data.instagram_external.url
"
>
<SerieWatchOnBar :document="serie" />
</AtomSidebarEntry>
<div>
<AtomSidebarEntry title="Tags" v-if="tags.length">
<div class="mt-8"></div>
<AtomTags :tags="tags" />
</AtomSidebarEntry>
</div>
<div>
<AtomSidebarEntry :title="$t('serie.share')">
<ShareActionBar class="mt-8" />
</AtomSidebarEntry>
</div>
</SingleSidebar>
<SliceZone :slices="serie.data.slices" :components="components" />
</SingleContainer>
<div class="container">
<!-- TODO types -->
<SliceZoneResolver :slices="data!.slices" />
</div>
</main>
</template>
<template>
<main class="pageSerie pb-48">
<SerieFeaturedCover :document="serie"></SerieFeaturedCover>
<SingleContainer :rows="serie.data.slices.length + 1">
<SingleSidebar>
<AtomDivider class="mt-0 mb-8 mobile background-[#303030]" />
<AtomSidebarEntry
:title="$t('serie.narrated')"
v-if="serie.data.narrator_copyright"
>
{{ serie.data.narrator_copyright }}
</AtomSidebarEntry>
<AtomSidebarEntry
:title="$t('serie.music')"
v-if="serie.data.narrator_copyright"
>
{{ serie.data.music_copyright }}
</AtomSidebarEntry>
<AtomSidebarEntry
:title="$t('serie.editing')"
v-if="serie.data.narrator_copyright"
>
{{ serie.data.editing_copyright }}
</AtomSidebarEntry>

<AtomSidebarEntry
class="mt-16"
:title="$t('serie.watch')"
v-if="
serie.data.youtube_external.url! ||
serie.data.vimeo_external.url ||
serie.data.instagram_external.url
"
>
<SerieWatchOnBar :document="serie" />
</AtomSidebarEntry>
<div>
<AtomSidebarEntry title="Tags" v-if="tags.length">
<div class="mt-8"></div>
<AtomTags :tags="tags" />
</AtomSidebarEntry>
</div>
<div>
<AtomSidebarEntry :title="$t('serie.share')">
<ShareActionBar class="mt-8" />
</AtomSidebarEntry>
</div>
</SingleSidebar>
<SliceZone :slices="serie.data.slices" :components="components" />
</SingleContainer>
<div class="container">
<!-- TODO types -->
<SliceZoneResolver :slices="data!.slices" />
</div>
</main>
</template>
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
and that I don't explain
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
but looking at cilium logs, I saw that my website container is also doing API calls to prismic
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
That could not explain our high prismic API usage
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
I see my browser calling for prismic client side when I browse the website, 2 calls to prismic, everything seems fine
44 replies
NNuxt
Created by sylr on 1/8/2025 in #❓・help
@nuxtjs/prismic high API usage
I've got 10 calls to prismic made every seconds by the node process
44 replies