import axios from "axios"; import Link from "next/link"; import React, { useEffect, useState } from "react"; export default function Content({ ids, providers }) { const [data, setData] = useState([]); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); async function fetchData() { setIsLoading(true); try { const res = await axios.get( `https://api.eucrypt.my.id/meta/anilist-manga/info/${ids}?provider=${providers}` ); const data = res.data; setData(data); setError(null); // Reset error state if data is successfully fetched } catch (error) { setError(error); } setIsLoading(false); } useEffect(() => { fetchData(); }, [providers, fetchData]); useEffect(() => { // console.log("Data changed:", data); }, [data]); if (error) { // Handle 404 Not Found error return
Chapters Not Available
; } // console.log(isLoading); return ( <>
{isLoading ? (

Loading...

) : data.chapters?.length > 0 ? ( data.chapters?.map((chapter, index) => { return (
Chapters {index + 1}
); }) ) : (

No Chapters Available

)}
); }