The Movie Database Support

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 *

4 replies (on page 1 of 1)

Jump to last post

Hi! How did you fix it? I have the same error, I'm doing a similar project.

@OlegShved said:
Hi! How did you fix it? I have the same error, I'm doing a similar project.

This user, @kunal@knk#0470 , has not accessed TMDb for a year.
I suggest you open a new thread explaining your problem.
If possible, show the API request you want to make that is causing the problem.

@ticao2 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, )

@OlegShved said:

@ticao2 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, )

As I said in my previous comment...

I suggest you open a new thread explaining your problem.
If possible, show the API request you want to make that is causing the problem.

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login