The Movie Database Support Forum

const GetHeaderWallpaper = async()=>{ try{ const {data} = await axios.get(/trending/all/day); let randomdata = data.results[(Math.random()*data.results.length).toFixed()]; setwallpaper(randomdata); console.log({randomdata}); } catch(error){ console.log("Error:",error); } };

2 Antworten (Seite 1 von 1)

Jump to last post

@Samyak.22 said:
after calling api empty array is getting in return
const GetHeaderWallpaper = async()=>{
try{
const {data} = await axios.get(/trending/all/day);
let randomdata = data.results[(Math.random()*data.results.length).toFixed()];
setwallpaper(randomdata);
console.log({randomdata});
}
catch(error){
console.log("Error:",error);
}
};

This code of yours builds an API Request.
Using the AXIOS tool.
What we need to know is which API Request is sent to our server.
Can you tell us what it is here?

Problems with API Request

In order for someone to help you with API Request questions,
it is critical that you post here the API Request you are sending to the TMDb server.
Remember to replace your Key with MY_KEY , YOUR_KEY , THE_KEY , or something like that.

Not the programming code/script you used to build the API Request.
But the API Request that is sent to the TMDb server.
Or the API Request you would like to send.

Es fehlt ein Film oder eine Serie? Logge dich ein zum Ergänzen.

Allgemein

s Fokus auf Suchfeld
p Profil öffnen
esc Fenster schließen
? Tastenkürzel anzeigen

Videos

b Zurück
e Bearbeiten

Staffeln

Nächste Staffel
Vorherige Staffel

Episoden

Nächste Episode
Vorherige Episode

Bilder

a Poster oder Hintergrundbild hinzufügen

Editieren

t Sprachauswahl öffnen
ctrl+ s Speichern

Diskussionen

n Neue Diskussion erstellen
w Beobachten an / aus
p Diskussion öffentlich / privat
c Diskussion öffnen / schließen
a Diskussionsverlauf anzeigen
r Auf Diskussion antworten
l Letzte Antwort anzeigen
ctrl+ enter Senden
Nächste Seite
Vorherige Seite

Einstellungen

Diesen Eintrag bewerten oder zu einer Liste hinzufügen?

Anmelden