File tree Expand file tree Collapse file tree 1 file changed +5
-15
lines changed
src/app/[locale]/certificates/[slug] Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -3,31 +3,21 @@ import { notFound } from "next/navigation";
33import Certificate from "@/features/certificate/Certificate" ;
44import { CertificateType } from "@/features/certificate/types" ;
55
6- export async function getCertificate ( slug : string ) {
7- try {
8- const response = await fetch ( `https://moonlight.hammercode.org/v1/certificates/${ slug } ` ) ;
9- if ( ! response . ok ) return null ;
10-
11- return response . json ( ) ;
12- } catch ( error ) {
13- console . error ( "Error fetching certificate:" , error ) ;
14- return null ;
15- }
16- }
17-
186type Props = {
197 params : {
208 slug : string ;
219 } ;
2210} ;
2311
2412const CertificateDetail = async ( { params } : Props ) => {
25- const certificate : CertificateType = await getCertificate ( params . slug ) ;
26- if ( ! certificate . name ) {
13+ const data = await fetch ( `https://moonlight.hammercode.org/v1/certificates/${ params . slug } ` ) ;
14+ const certificateDetail : CertificateType = await data . json ( ) ;
15+
16+ if ( ! certificateDetail . name ) {
2717 return notFound ( ) ;
2818 }
2919
30- return < Certificate certificate = { certificate } /> ;
20+ return < Certificate certificate = { certificateDetail } /> ;
3121} ;
3222
3323export default CertificateDetail ;
You can’t perform that action at this time.
0 commit comments