Return specific error message if location doesn't exist

This commit is contained in:
2022-07-30 15:16:19 +02:00
parent 6f445f6191
commit 38deb96197
3 changed files with 10 additions and 7 deletions

View File

@@ -27,8 +27,6 @@
export let totalPhotos: number
export let product: any
console.log(product)
dayjs.extend(relativeTime)
const { params } = $page

View File

@@ -76,8 +76,11 @@ export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutp
`)
const { data: { location: location, photos, total_published, product }} = res
if (params.country !== location[0].country.slug || !location.length) {
return { status: 404 }
if (!location.length || location.length && params.country !== location[0].country.slug) {
return {
status: 404,
body: Error("This location is not available… yet,"),
}
}
return {