updated useFetch requests in onMounted to use
This commit is contained in:
parent
592bbb1dd3
commit
f7af5501da
4 changed files with 62 additions and 75 deletions
|
@ -31,21 +31,19 @@ const updateLists = async function () {
|
|||
headers["Authorization"] = `Token ${useCookie("token").value}`;
|
||||
}
|
||||
|
||||
const { data, error } = await useFetch<MovieList[]>(
|
||||
`${config.public.apiURL}/lists`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: headers,
|
||||
},
|
||||
);
|
||||
|
||||
if (error.value) {
|
||||
if (error.value.statusCode === 401) {
|
||||
navigateTo("/");
|
||||
}
|
||||
} else {
|
||||
lists.value = data.value || [];
|
||||
}
|
||||
await $fetch<MovieList[]>(`${config.public.apiURL}/lists`, {
|
||||
method: "GET",
|
||||
headers: headers,
|
||||
})
|
||||
.then((data) => {
|
||||
lists.value = data || [];
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.statusCode === 401) {
|
||||
useCookie("token").value = null;
|
||||
navigateTo("/");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue