updated search to use typescript and composition api

This commit is contained in:
Edward Tirado Jr 2025-04-13 01:39:23 -05:00
parent 2187c2637b
commit 6b4617cf3d
6 changed files with 226 additions and 159 deletions

View file

@ -18,18 +18,24 @@
<script lang="ts" setup>
import type { MovieList } from "~/types/movielist";
import { useCookie } from "#app";
const lists = defineModel<MovieList[]>("movie_list", { default: [] });
const updateLists = async function () {
let config = useRuntimeConfig();
let headers: any = {
"Content-type": "application/json",
};
if (typeof useCookie("token").value !== "undefined") {
headers["Authorization"] = `Token ${useCookie("token").value}`;
}
const { data, error } = await useFetch<MovieList[]>(
`${config.public.apiURL}/lists`,
{
method: "GET",
headers: {
"Content-type": "application/json",
Authorization: `Token ${useCookie("token").value}`,
},
headers: headers,
},
);