<script lang="ts">
	import hljs from 'highlight.js';
	import type { Model } from '../+page.svelte';

	let { model }: { model: Model } = $props();
</script>

To create a new class via the API you can:
<pre style="font-family: Fira Code;">{@html hljs.highlight(
		`let form = new FormData();
form.append('json_data', JSON.stringify({
	id: '${model.id}',
	name: 'New class name'
}));
form.append('file', file, 'file');

const headers = new Headers();
headers.append('response-type', 'application/json');
headers.append('token', token);

const r = await fetch('${window.location.protocol}//${window.location.hostname}/models/data/class/new', {
	method: 'POST',
	headers: headers,
	body: form
});`,
		{ language: 'javascript' }
	).value}</pre>
