Files
housesof/src/routes/index.ts
Félix Péault ecc051a439 Update Homepage query
Filter published photos only
2022-05-31 18:34:07 +02:00

43 lines
1.1 KiB
TypeScript

import type { RequestEvent, RequestHandlerOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api'
export async function get({}: RequestEvent): Promise<RequestHandlerOutput> {
try {
const res = await fetchAPI(`
query {
photo (
limit: 11,
sort: ["-date_created"],
filter: { status: { _eq: "published" }},
) {
slug
title
city
location {
name
slug
country {
slug
name
flag { id }
}
}
image { id }
}
}
`)
const { data } = res
return {
body: {
photos: data.photo
}
}
} catch (error) {
return {
status: 404,
body: error,
}
}
}