fixes notifications & trail recommendations
This commit is contained in:
@@ -2,25 +2,20 @@ import { TrailRecommendSchema } from '$lib/models/api/trail_schema';
|
||||
import type { Trail } from '$lib/models/trail';
|
||||
import { pb } from '$lib/pocketbase';
|
||||
import { handleError } from '$lib/util/api_util';
|
||||
import { error, json, type RequestEvent } from '@sveltejs/kit';
|
||||
import { ClientResponseError } from 'pocketbase';
|
||||
import { json, type RequestEvent } from '@sveltejs/kit';
|
||||
|
||||
export async function GET(event: RequestEvent) {
|
||||
try {
|
||||
const searchParams = Object.fromEntries(event.url.searchParams);
|
||||
const safeSearchParams = TrailRecommendSchema.parse(searchParams);
|
||||
|
||||
const r = await event.fetch(pb.buildURL("/trail/recommend?" + new URLSearchParams({
|
||||
|
||||
const r = await pb.send("/trail/recommend?" + new URLSearchParams({
|
||||
size: safeSearchParams.size?.toString() ?? ""
|
||||
})));
|
||||
}), {
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
if (!r.ok) {
|
||||
const response = await r.json()
|
||||
console.error(response)
|
||||
throw new ClientResponseError({ status: response.code, response })
|
||||
}
|
||||
|
||||
const result: Trail[] = await r.json();
|
||||
const result: Trail[] = r;
|
||||
|
||||
for (const t of result) {
|
||||
if (!t.author || !pb.authStore.record) {
|
||||
|
||||
Reference in New Issue
Block a user