Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
fix: add missing useeffect dependency #4
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Nov 18, 2023
1 parent 2a7a844 commit 3608f9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default async function Home() {
<div className="p-2">
<Announcement text="完善中..." />
<Banners data={bannerData.banners} />
{process.env.NODE_ENV === 'development' && <StarPick />}
{/* {process.env.NODE_ENV === 'development' && <StarPick />} */}
<StarPick />
<RecommendSongs />
<HotSongs data={songsHot.data} />
<Playlist data={PlaylistData.playlists} />
Expand Down
3 changes: 2 additions & 1 deletion app/ui/StarPick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect, useState } from 'react';
import Link from 'next/link';
import Avatar from './Avatar';

// TODO: starpick fetch failed
export default function StarPick() {
const [starPick, setStarPick] = useState<StarPick>();
const [loading, setLoading] = useState(true);
Expand All @@ -18,7 +19,7 @@ export default function StarPick() {
console.log(error);
setLoading(true);
}
});
}, []);

return (
<div className="m-2">
Expand Down
10 changes: 2 additions & 8 deletions lib/fetchData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,8 @@ async function fetchData(
const urlWithParams = addParams(finalURL, params);

try {
const response = await fetch(urlWithParams, mergedOptions);
// console.log(urlWithParams);

if (!response.ok) {
throw new Error(`Failed to fetch data. Status: ${response.status}`);
}
const data = await response.json();
return data;
const res = await fetch(urlWithParams, mergedOptions);
return await res.json();
} catch (error) {
console.error('Error in fetchData:', error);
throw error;
Expand Down

0 comments on commit 3608f9f

Please sign in to comment.