enzostvs's picture
enzostvs HF staff
add metadata auto generated on first load of the model
108f30f
raw
history blame
502 Bytes
import { error } from '@sveltejs/kit';
/** @type {import('./$types').PageLoad} */
export async function load({ params, fetch }) {
const { userId, slug } = params;
const model_request = await fetch(`/api/models/${userId + "@" + slug}?full=true&metadata=true`, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
})
const data = await model_request?.clone().json().catch(() => null);
if (!data?.model) {
return error(404, 'Not found');
}
return data
}