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

View File

@ -1,11 +1,16 @@
import { error, json, type RequestEvent } from '@sveltejs/kit'; import { error, json, type RequestEvent } from '@sveltejs/kit';
export async function POST({ request }: RequestEvent) { 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) { if (!request.body) {
error(400, 'no body in request'); 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' }); return json({ msg: 'to be implemented' });
} }