You've already forked AstralRinth
fix: throw error on fail so it doesnt cache (#5023)
* fix: throw error on fail so it doesnt cache * lint --------- Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
@@ -7,7 +7,14 @@ export default defineCachedEventHandler(
|
||||
const config = useRuntimeConfig(event)
|
||||
const apiBaseUrl = config.apiBaseUrl || config.public.apiBaseUrl
|
||||
|
||||
return await $fetch<Labrinth.Tags.v2.GameVersion[]>(`${apiBaseUrl}tag/game_version`)
|
||||
const response = await $fetch<Labrinth.Tags.v2.GameVersion[]>(`${apiBaseUrl}tag/game_version`)
|
||||
|
||||
// nitro wont cache if we throw an error
|
||||
if (!response || !Array.isArray(response)) {
|
||||
throw createError({ statusCode: 502, message: 'Invalid response from API' })
|
||||
}
|
||||
|
||||
return response
|
||||
},
|
||||
{
|
||||
maxAge: CACHE_MAX_AGE,
|
||||
|
||||
Reference in New Issue
Block a user