mirror of
https://github.com/khairul169/code-share.git
synced 2025-04-29 00:59:37 +07:00
13 lines
348 B
TypeScript
13 lines
348 B
TypeScript
import { PageContext } from "vike/types";
|
|
|
|
export const data = async (ctx: PageContext) => {
|
|
const id = ctx.routeParams?.id;
|
|
const post = await fetch(
|
|
"https://jsonplaceholder.typicode.com/posts/" + id
|
|
).then((response) => response.json());
|
|
|
|
return { post, title: post?.title };
|
|
};
|
|
|
|
export type Data = Awaited<ReturnType<typeof data>>;
|