The Movie Database Support

I trying to make a page that recommends TV Shows based on ID

I successfully made a details page but when I tried to make a recommendations page it is showing error
the console output for the details page => https://api.themoviedb.org/3/tv/237480?language=en-US&api_key

I was able to successfully made a recommendation page for the movies but failed for tv_shows

api that I am using ->https://api.themoviedb.org/3/tv/${id}/recommendations?language=en-US&api_key=${publicKey}

console output => https://api.themoviedb.org/3/tv/undefined/recommendations?language=en-US

6 erantzun (1(e)tik 1. orrian)

Jump to last post

@Masheirin said:
TMDB TV details api error
I trying to make a page that recommends TV Shows based on ID
I successfully made a details page but when I tried to make a recommendations page it is showing error
the console output for the details page =>
https://api.themoviedb.org/3/tv/237480?language=en-US&api_key
I was able to successfully made a recommendation page for the movies but failed for tv_shows

api that I am using ->https://api.themoviedb.org/3/tv/${id}/recommendations?language=en-US&api_key=${publicKey}
console output => https://api.themoviedb.org/3/tv/undefined/recommendations?language=en-US

Considering the "undefined" in the console output, I assume there must be some problem with the Series ID placement.
If that's the case, I don't know how to help you.
It seems you didn't enter the Series ID.

https://api.themoviedb.org/3/tv/${id}?language=en-US&api_key=${publicKey}

πŸ‘†This is the one I am using for tv details but this is working fine

https://api.themoviedb.org/3/movie/${id}?language=en-US&api_key=${publicKey}

πŸ‘† This is the I am using for Movies but this is showing error

The one for movies is adding undefined to every id name

When I posted this ques atleast this one was working but now it is also broken 😭😭😭

When you get "undefined" in the request, that means that the variable ${id} hasn't been initialised in your code.

import { useState, useEffect } from 'react';
import axios from 'axios';
import { useParams } from 'react-router-dom';

function MDetails() {
    let { id } = useParams();
    const [MovieDetail, setMovieDetail] = useState({});
    const publicKey = import.meta.env.VITE_PUBLIC_KEY;

    useEffect(() => {
        const url = `https://api.themoviedb.org/3/movie/${id}?language=en-US&api_key=${publicKey}`;

        axios
            .get(url)
            .then((response) => {
                setMovieDetail(response.data);
            })
            .catch((error) => {
                console.error("Error fetching movie details:", error);
            });
    }, [id, publicKey]);

    if (!MovieDetail.title) {
        return <div>Loading...</div>;
    }


Sorry, but we do not debug user code.

OK

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

Ezarpenak

Elementu hau kalifikatu edo zerrenda batera gehitzea nahi al duzu?

Saioa hasi