„The Movie Database“ palaikymas

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 atsakė (on page 1 iš 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

Negalite rasti filmo ar TV laidos? Prisijunkite, kad sukurtumėte.

Bendras

s susitelkti į paieškos juostą
p profilio meniu
esc uždarykite atidarytą langą
? spartieji klavišai

Medijų puslapiuose

b grįžkite atgal (arba tėvams leidus)
e į redagavimo puslapį

TV sezono puslapiuose

(dešinė rodyklė) sekantis sezonas
(kairė rodyklė) ankstesnis sezonas

TV epizodo puslapiuose

(dešinė rodyklė) sekantis epizodas
(kairė rodyklė) ankstesnis epizodas

Visuose atvaizdžio puslapiuose

a atverti atvaizdžio pridėjimo langą

Visuose redagavimo puslapiuose

t vertimo parinktys
ctrl+ s pateikti formą

Diskusijų puslapiuose

n sukurti naują diskusiją
w perjungti peržiūros būseną
p perjungti viešasis / privatus
c perjungti uždaryti / atidaryti
a peržiūrėti aktyvumą
r atsakyti į pokalbį
l į paskutinį atsakymą
ctrl+ enter pateikti pranešimą
(dešinė rodyklė) sekantis puslapis
(kairė rodyklė) ankstesnis puslapis

Nustatymai

Norite įvertinti ar įtraukti šį elementą į sąrašą?

Prisijungti