16 lines
No EOL
480 B
TypeScript
16 lines
No EOL
480 B
TypeScript
import { type LoaderFunctionArgs } from "react-router";
|
|
|
|
export async function loader({ params, context }: LoaderFunctionArgs) {
|
|
const { postId } = params;
|
|
|
|
// 'context.cloudflare.env' contains your bindings
|
|
const { API } = context.cloudflare.env;
|
|
|
|
// Use the Service Binding to talk to the backend
|
|
// This is much faster than a standard fetch over the internet
|
|
const response = await API.fetch(
|
|
`http://internal/posts/${postId}/view`
|
|
);
|
|
|
|
return response;
|
|
} |