תמיכת The Movie Database

So I'm trying to fetch this end-point /tv/tv_id/images

in browser, https://api.themoviedb.org/3/tv/125988/images?api_key=### everything is fine, no problem at all. it gave me the backdrops, logos and more.

but in my app it returned status 200, everything is fine. but the result is weird.

It returned, backdrops: 0; id: 125988; logo: 0;

below is my code, other endpoint such as the Trending, movie details is fine, just this one. so I'm stuck, i thought this was caused by limiter, do some throttling so my app can only call 3 api per second, same.

import axios from "axios";
import { useEffect, useState } from "react";

const useTMDB = (request = "/trending/movie/day") => {
  // Data State
  const [data, setData] = useState(null);
  const [error, setError] = useState(false);
  const [loading, setLoading] = useState(true);

  // Request Options
  const options = {
    method: "GET",
    url: `https://api.themoviedb.org/3${request}`,
    params: { language: "en-US" },
    headers: {
      accept: "application/json",
      Authorization:
        "Bearer ###",
    },
  };

  // Caller Function
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await axios.request(options);
        setData(response.data);
      } catch (error) {
        setError(error);
      } finally {
        setLoading(false);
      }
    };

    // Launch the Caller function
    fetchData();
  }, [request]);

  return { data: data, loading: loading, error: error };
};

export default useTMDB;

4 תגובות (בדף 1 מתוך 1)

Jump to last post

if I do it like this

 useEffect(() => {
    const getLogo = async () => {
      fetch(url)
        .then((res) => res.json())
        .then((data) => {
          setLogoPath(
            `https://image.tmdb.org/t/p/w500${data?.logos[0]?.file_path}`
          );
        });
    };

    getLogo();
  }, []);

it returned the result with their arrays and object perfectly, i still not understand the problem lol

@kazuhira_miller said:
Fetching images with 0 results in app, normal in browser
So I'm trying to fetch this end-point /tv/tv_id/images

in browser, https://api.themoviedb.org/3/tv/125988/images?api_key=###
everything is fine, no problem at all. it gave me the backdrops, logos and more.

but in my app it returned status 200, everything is fine.
but the result is weird.

It returned,
backdrops: 0;
id: 125988;
logo: 0;

What we need to know is:
What is the API Request that your code is making?
Which one is sent to the TMDb server?
I'm not a programmer, so I can't figure out your code.

A guess from me.
Your API Request that is sending and receiving this incorrect response probably has "&language='" specified.
If it is specified, please tell us what the parameter specified in "&language="' is.
And, if it is specified, you need to ALSO use the "&include_image_language=" parameter specifying one or more languages ​​of images that you want to receive.

Yeah it's the params, my mistake.

I try to filter it like this

params: { language: "en-US" },

while it should be like this

params: {include_image_language: 'en'},

should've gone through the document more carefully.

.לא מצאת סרט או סדרה? היכנס כדי ליצור אותם

עולמי

s התמקד בשורת החיפוש
p פתח תפריט פרופיל
esc סגור חלון פתוח
? פתח חלון קיצורי דרך של מקלדת

בדפי מדיה

b לך חזרה (או אל הורה אם ישים)
e לך אל דף עריכה

בדפי עונות

(חץ ימני) לך אל העונה הבאה
(חץ שמאלי) לך אל העונה הקודמת

בדפי סדרות

(חץ ימני) לך אל הפרק הבא
(חץ שמאלי) לך אל הפרק הקודם

בכל דפי תמונה

a פתח חלון הוספת תמונה

בכל דפי עריכה

t פתח בוחר תרגום
ctrl+ s הגש טופס

בדפי דיון

n צור דיון חדש
w עורר מעמד צפייה
p עורר ציבורי/פרטי
c עורר סגירה/פתיחה
a פתח פעילות
r השב אל דיון
l לך אל תשובה אחרונה
ctrl+ enter הגש את הודעתך
(חץ ימני) הדף הבא
(חץ שמאלי) הדף הקודם

הגדרות

?רוצה לדרג או להוסיף פריט אל רשימה

היכנס