From bffa8f49b04676198218369ce55af95dbb8ff3a3 Mon Sep 17 00:00:00 2001 From: valere Date: Sun, 6 Oct 2024 19:40:05 +0200 Subject: [PATCH] FEAT: details page --- components/list.vue | 8 ++++---- nuxt.config.ts | 7 ++++++- pages/details/[id].vue | 17 +++++++++++++++-- server/api/details/[id].ts | 13 +++++++++++++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 server/api/details/[id].ts diff --git a/components/list.vue b/components/list.vue index 3a3d288..712d4a3 100644 --- a/components/list.vue +++ b/components/list.vue @@ -10,14 +10,15 @@ {{ films.length }} - - + {{ film.title }} {{ film.original_title }} {{ film.vote_count }} {{ film.release_date }} + {{ film.id }} @@ -25,8 +26,7 @@ diff --git a/server/api/details/[id].ts b/server/api/details/[id].ts new file mode 100644 index 0000000..f0db726 --- /dev/null +++ b/server/api/details/[id].ts @@ -0,0 +1,13 @@ +import fetch from 'node-fetch' + +export default eventHandler(async (req) => { + const id = req.context.params?.id || '' + const url = `https://api.themoviedb.org/3/movie/${id}` + const config = useRuntimeConfig(req) + + const response = await fetch(url, { + method: 'get', + headers: { 'Content-Type': 'application/json', 'Authorization': config.API_BEARER } + }) + return await response.json() +})