The Movie Database サポート

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 replies (on page 1 of 1)

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

映画やテレビ番組が見つかりませんか?ログインして作成してください。

全般

s 検索バーに移動する
p プロファイルメニューを開く
esc 開いているウィンドウを閉じる
? キーボードショートカットウィンドウを開く

メディアのページ

b 戻る(または該当する場合は親に)
e 編集ページに行く

テレビ番組のシーズンのページ

(右矢印)次のシーズンに行く
(左矢印)前のシーズンに戻る

テレビ番組のエピソードのページ

(右矢印)次のエピソードに進む
(左矢印)前のエピソードに戻る

全ての画像のページ

a 画像追加ウィンドウを開く

全ての編集ページ

t 翻訳選択を開く
ctrl+ s フォームを送信する

ディスカッションのページ

n 新しいディスカッションを作成する
w 監視ステータスを切り替える
p 公開/非公開を切り替える
c 閉じる/開くを切り替える
a アクティビティを開く
r ディスカッションに返信
l 最後の返事に行く
ctrl+ enter メッセージを送信する
(右矢印)次のページ
(左矢印)前のページ

設定

このアイテムを評価したり、リストに追加したりしたいですか?

ログイン

メンバーではありませんか?

登録してコミュニティに参加