Skip to content

Commit

Permalink
Update index.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
kalebzaki4 committed Jan 22, 2025
1 parent a4aba5c commit 34f09ad
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Paginas/Inicio/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import '../../message.css';
export default function Inicio() {
const [loading, setLoading] = useState(true);
const [animes, setAnimes] = useState([]);
const [lancamentos, setLancamentos] = useState([]);

useEffect(() => {
const fetchAnimes = async () => {
try {
const response = await axios.get("https://api.jikan.moe/v4/anime");
setAnimes(response.data.data);
const sortedAnimes = response.data.data.sort((a, b) => new Date(b.start_date) - new Date(a.start_date));
const latestReleases = sortedAnimes.slice(0, 10);
setAnimes(sortedAnimes);
setLancamentos(latestReleases);
setLoading(false);
} catch (error) {
console.error("Error fetching anime data:", error);
Expand All @@ -38,8 +42,8 @@ export default function Inicio() {
<ListaDeAnimesHorizontal
title="Lançamentos"
description="Veja os animes mais recentes"
animes={animes}
animes={lancamentos}
/>
</>
);
}
};

0 comments on commit 34f09ad

Please sign in to comment.