Update API from meeting

This commit is contained in:
schooltechx 2023-04-07 22:59:53 +07:00
parent 40f7e878c9
commit b2083ebae2
13 changed files with 125 additions and 67 deletions

View file

@ -1,17 +1,16 @@
import type { PageServerLoad } from './$types'
//import type {Exam} from '$lib/data/CMSDataType'
import { error } from '@sveltejs/kit'
import exams from "$lib/data/qualify-exam.json"
export const load: PageServerLoad = async ({params}) => {
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({params,fetch}) => {
const id = params.id+""
const post = exams.find((q)=>{
return q.id===id
})
if(post)
return post
else
throw error(404,{message:"ค้นหาโพสเกี่ยวกับการคัดเลือกไม่พบ"})
const res = await fetch("/api/qualifying/"+id)
if(res.status==404){
throw error(404,{message:`ค้นหาข้อมูลสอบคัดเลือก ${id}ไม่พบ`})
}
if(!res.ok){
throw error(500,{message:`พบข้อผิดพลาดเกี่ยวกับข้อมูลสอบคัดเลือก ${id}`})
}
const post = await res.json()
return post
}

View file

@ -1,9 +1,6 @@
<script lang="ts">
import ver from "$lib/ver.json"
import type { PageData } from './$types'
export let data: PageData;
</script>
<section>
<div class="p-one parallax-inner">