import Results from '@/components/Results';
const API_KEY = process.env.API_KEY;
export default async function Home({ searchParams }) {
const genre = searchParams.genre || 'fetchTrending';
const res = await fetch(
`https://api.themoviedb.org/3${
genre === 'fetchTopRated' ? `/movie/top_rated` : `/trending/all/week`
}?api_key=${API_KEY}&language=en-US&page=1`,
{ next: { revalidate: 10000 } }
);
const data = await res.json();
if (!res.ok) {
throw new Error('Failed to fetch data');
}
const results = data.results;
return (
<div>
<Results results={results} />
</div>
);
}
*This is my page.js files code, plz help me to solve the issue of ' Failed to fetch data ' error, AND API INVALID error after execution and Testing the response of the key+URL with your testing link and also with an vs code extension ' Rapidapi Client ' API tester, I'm stuck with this API ERROR Sh$t from 2-3 weeks & Can't Further Progress in completion of my project *
لم تجد الفلم أو المسلسل ؟ سجل دخولك و انشئها
هل تريد تقييم او اضافة هذا العنصر للقائمة؟
لست عضو؟