[chore] Switch Homepage and Photos to page endpoints
This commit is contained in:
39
src/routes/index.ts
Normal file
39
src/routes/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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"]) {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user