From 9f28b6d9160fee5eff92d1d9849191f2f12faeab Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 14 Feb 2022 16:33:38 +0000 Subject: Initial commit --- src/routes/todos/_api.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/routes/todos/_api.ts (limited to 'src/routes/todos/_api.ts') diff --git a/src/routes/todos/_api.ts b/src/routes/todos/_api.ts new file mode 100644 index 0000000..f8bcf73 --- /dev/null +++ b/src/routes/todos/_api.ts @@ -0,0 +1,22 @@ +/* + This module is used by the /todos and /todos/[uid] + endpoints to make calls to api.svelte.dev, which stores todos + for each user. The leading underscore indicates that this is + a private module, _not_ an endpoint — visiting /todos/_api + will net you a 404 response. + + (The data on the todo app will expire periodically; no + guarantees are made. Don't use it to organise your life.) +*/ + +const base = 'https://api.svelte.dev'; + +export async function api(request: Request, resource: string, data?: Record) { + return fetch(`${base}/${resource}`, { + method: request.method, + headers: { + 'content-type': 'application/json' + }, + body: data && JSON.stringify(data) + }); +} -- cgit