playing around with submission some more
This commit is contained in:
parent
e674f6e118
commit
395bd3394e
@ -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>
|
||||||
|
|
||||||
|
@ -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' });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user