1
0

playing around with submission some more

This commit is contained in:
Nicola Clark 2024-11-16 15:11:24 -06:00
parent e674f6e118
commit 395bd3394e
Signed by: nicola
GPG Key ID: 3E1710E7FF08956C
2 changed files with 13 additions and 5 deletions

View File

@ -18,10 +18,13 @@
async function performRender(event: MouseEvent) {
event.preventDefault();
const data = new FormData();
data.append('markdown', markdown);
data.append('stylesheet', stylesheet);
console.log(await fetch('/render', { method: 'POST', body: data }));
console.log(
await fetch('/render', {
method: 'POST',
body: await output,
headers: { 'content-type': 'text/html' },
}),
);
}
</script>

View File

@ -1,11 +1,16 @@
import { error, json, type RequestEvent } from '@sveltejs/kit';
export async function POST({ request }: RequestEvent) {
if (!(request.headers.get('Content-Type') ?? 'bad').includes('text/html')) {
error(400, 'request body not HTML');
}
if (!request.body) {
error(400, 'no body in request');
}
console.log(request);
const input = await request.text();
console.log('received input: ', input);
return json({ msg: 'to be implemented' });
}