Skip to content

Commit

Permalink
fix: rewrite request from axios to Fetch (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
gauthier-th authored Aug 7, 2024
1 parent 2348f23 commit 9aee888
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/MovieDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -171,7 +169,7 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => {
}

if (!data) {
return <Error statusCode={404} />;
return <ErrorPage statusCode={404} />;
}

const showAllStudios = data.productionCompanies.length <= minStudios + 1;
Expand Down Expand Up @@ -351,11 +349,12 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => {
const onClickDeleteWatchlistBtn = async (): Promise<void> => {
setIsUpdating(true);
try {
const response = await axios.delete<Watchlist>(
'/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(
<span>
{intl.formatMessage(messages.watchlistDeleted, {
Expand Down

0 comments on commit 9aee888

Please sign in to comment.