11export default async ( req , res ) => {
22 // Get the ID to show
3- const { query } = req
4- const { slug } = query
5- const id = slug [ 0 ]
3+ const { query } = req ;
4+ const { slug } = query ;
5+ const id = slug [ 0 ] ;
66
77 // Get the data
88 const fetchRes = await fetch ( `https://api.tvmaze.com/shows/${ id } ` ) ;
99 const show = await fetchRes . json ( ) ;
1010
1111 // Show could not be found
12- if ( fetchRes . status > 200 ) {
13- res . status ( 404 )
12+ if ( fetchRes . status > 200 ) {
13+ res . status ( 404 ) ;
1414 res . json ( {
15- error : ' Show could not be found :('
16- } )
17- return
15+ error : " Show could not be found :(" ,
16+ } ) ;
17+ return ;
1818 }
1919
20- res . status ( 200 )
20+ res . status ( 200 ) ;
2121 res . json ( {
22- title : 'API route: catch-all endpoint' ,
23- description : 'This endpoint fetches a TV show from an external API. ' +
24- 'It is a catch-all endpoint. ' +
25- 'The first URL parameter determines the ID of the show to fetch. ' +
26- 'You can change the URL to anything else, such as /api/1871/whatever/path/you/want' ,
22+ title : "API route: catch-all endpoint" ,
23+ description :
24+ "This endpoint fetches a TV show from an external API. " +
25+ "It is a catch-all endpoint. " +
26+ "The first URL parameter determines the ID of the show to fetch. " +
27+ "You can change the URL to anything else, such as /api/1871/whatever/path/you/want" ,
2728 slug : slug ,
28- viewCode : 'https://github.com/FinnWoelm/next-on-netlify-demo/tree/master/pages/api/[...slug].js' ,
29- goHome : 'https://next-on.netlify.app' ,
29+ viewCode :
30+ "https://github.com/FinnWoelm/next-on-netlify-demo/tree/master/pages/api/[...slug].js" ,
31+ goHome : "https://next-on.netlify.app" ,
3032 show : {
3133 id : show . id ,
3234 name : show . name ,
@@ -35,7 +37,7 @@ export default async (req, res) => {
3537 status : show . status ,
3638 premiered : show . premiered ,
3739 officialSite : show . officialSite ,
38- averageRating : show . rating ?. average
39- }
40- } )
41- }
40+ averageRating : show . rating ?. average ,
41+ } ,
42+ } ) ;
43+ } ;
0 commit comments