Files
sites/src/routes/getPosts/+server.js

12 lines
453 B
JavaScript

import { env } from '$lib';
import { error, json, text } from '@sveltejs/kit';
import { get } from 'svelte/store';
import { site_id } from '../store';
/** @type {import('./$types').RequestHandler} */
export async function GET({fetch, url}) {
const offset = url.searchParams.get("offset") || 0;
const postsRes = await fetch(env.api_url + `/blog?blog_id=${get(site_id)}&offset=${offset}`).then(x=>x.json());
return json(postsRes.articles);
}