Reputation: 1
function DetailAnime() {
const [detailAnime, setDetailAnime] = useState([]);
const [pageAnime, setPageAnime] = useState(1);
const { id } = useParams([]);
const { pathname } = useLocation();
useEffect(() => {
if(pathname.split('/').includes('popular')){
getAnimePopular(pageAnime).then((res) => {
setDetailAnime(res)
})
} else {
getAnimeList(pageAnime).then((res) => {
setDetailAnime(res)
console.log(res)
});
}
}, [pathname, pageAnime]);
I have issue to updating page when i click detailAnime, could you help me?
//api url const apiUrl = 'https://api.jikan.moe/v4/';
export const getAnimeList = async (page) => {
const anime = await axios.get(${apiUrl}/anime?page=${page}
);
return anime.data.data;
}
Upvotes: 0
Views: 31
Reputation: 1518
As far you have address your question, It looks like the issue is in your function getAnimeList
where you have passing the url incorrectly, having spaces and missing backtick(``).
// your api url
const apiUrl = 'https://api.jikan.moe/v4/';
export const getAnimeList = async (page) => {
const anime = await axios.get(`${ apiUrl }anime?page=${ page }`);
return anime.data.data;
}
Upvotes: 0