import {qualifyingBase} from '$lib/data/CMSDataType' import type {Exam} from '$lib/data/CMSDataType' import { error } from '@sveltejs/kit' import dayjs from 'dayjs' import type { PageServerLoad } from './$types' export const load: PageServerLoad = async ({params,fetch}) => { const id = params.id+"" const res = await fetch(qualifyingBase+"/qualifying/"+id) if(res.status==404){ throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`}) } if(!res.ok){ throw error(500,{message:`พบข้อผิดพลาดเกี่ยวกับข้อมูลสอบคัดเลือก ${id}`}) } const post:Exam = await res.json() post.date= post.start? dayjs(post.start).format("DD MMM BBBB"):"" return post }