diff --git a/src/pages/lists/[id].vue b/src/pages/lists/[id].vue index 77b717d..e662f5c 100644 --- a/src/pages/lists/[id].vue +++ b/src/pages/lists/[id].vue @@ -69,6 +69,7 @@ import "lazysizes"; import type { MovieList } from "~/types/movielist"; import type { Movie } from "~/types/movie"; import Modal from "~/components/Modal.vue"; +import { useCookie } from "#app"; const list_id = ref(0); const list = defineModel("movie_list", { default: [] }); @@ -83,12 +84,17 @@ const hide_scheduled = ref(false); const getList = async function (list_id: number) { let config = useRuntimeConfig(); + let headers: any = { + "Content-type": "application/json", + }; + + if (typeof useCookie("token").value !== "undefined") { + headers["Authorization"] = `Token ${useCookie("token").value}`; + } + $fetch(`${config.public.apiURL}/lists/${list_id}`, { method: "GET", - headers: { - "Content-type": "application/json", - Authorization: `Token ${useCookie("token").value}`, - }, + headers: headers, }) .then((data) => { list.value = data; diff --git a/src/pages/schedule/index.vue b/src/pages/schedule/index.vue index 8cf2637..7c55c4c 100644 --- a/src/pages/schedule/index.vue +++ b/src/pages/schedule/index.vue @@ -102,13 +102,17 @@ const getSchedule = async function (previous = false) { let params = ""; if (previous) params = "?past_showings=true"; + let headers: any = { + "Content-type": "application/json", + }; + + if (typeof useCookie("token").value !== "undefined") { + headers["Authorization"] = `Token ${useCookie("token").value}`; + } + await $fetch(`${config.public.apiURL}/schedules/1${params}`, { method: "GET", - headers: { - Accept: "application/json", - "Content-type": "application/json", - Authorization: `Token ${useCookie("token").value}`, - }, + headers: headers, }) .then((data) => { if (previous) {