From 9aee8887d3cca6e018f4be1c8400c22e86bf8dab Mon Sep 17 00:00:00 2001 From: Gauthier Date: Wed, 7 Aug 2024 14:33:44 +0200 Subject: [PATCH] fix: rewrite request from axios to Fetch (#920) --- src/components/MovieDetails/index.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/MovieDetails/index.tsx b/src/components/MovieDetails/index.tsx index b565fdb10..b18d506ce 100644 --- a/src/components/MovieDetails/index.tsx +++ b/src/components/MovieDetails/index.tsx @@ -26,7 +26,7 @@ import useLocale from '@app/hooks/useLocale'; import useSettings from '@app/hooks/useSettings'; import { Permission, useUser } from '@app/hooks/useUser'; import globalMessages from '@app/i18n/globalMessages'; -import Error from '@app/pages/_error'; +import ErrorPage from '@app/pages/_error'; import { sortCrewPriority } from '@app/utils/creditHelpers'; import defineMessages from '@app/utils/defineMessages'; import { refreshIntervalHelper } from '@app/utils/refreshIntervalHelper'; @@ -49,9 +49,7 @@ import { type RatingResponse } from '@server/api/ratings'; import { IssueStatus } from '@server/constants/issue'; import { MediaStatus, MediaType } from '@server/constants/media'; import { MediaServerType } from '@server/constants/server'; -import type { Watchlist } from '@server/entity/Watchlist'; import type { MovieDetails as MovieDetailsType } from '@server/models/Movie'; -import axios from 'axios'; import { countries } from 'country-flag-icons'; import 'country-flag-icons/3x2/flags.css'; import { uniqBy } from 'lodash'; @@ -171,7 +169,7 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => { } if (!data) { - return ; + return ; } const showAllStudios = data.productionCompanies.length <= minStudios + 1; @@ -351,11 +349,12 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => { const onClickDeleteWatchlistBtn = async (): Promise => { setIsUpdating(true); try { - const response = await axios.delete( - '/api/v1/watchlist/' + movie?.id - ); + const res = await fetch(`/api/v1/watchlist/${movie?.id}`, { + method: 'DELETE', + }); + if (!res.ok) throw new Error(); - if (response.status === 204) { + if (res.status === 204) { addToast( {intl.formatMessage(messages.watchlistDeleted, {