Β© 2026 Hedgehog Software, LLC
// src/routes/index.tsx import { createAsync, query } from "@solidjs/router"; import { For } from "solid-js"; const getPosts = query(async () => { const posts = await fetch("http://localhost:3001/api/hello"); return await posts.json(); }, "posts"); export default function Home() { const posts = createAsync(() => getPosts()); return ( <section> <ul> <For each={posts()}>{(post) => <li>{post.title}</li>}</For> </ul> </section> ); }
// src/routes/api/hello.ts import { APIEvent, json } from "solid-start"; export async function GET() { console.log("testing") return json({ message: "Hello from the backend!" }); } export async function POST({ request }: APIEvent) { const body = await request.json(); return new Response(JSON.stringify({ echo: body }), { headers: { "Content-Type": "application/json" } }); }
GET
POST