Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
JSON to HTML output using TMDB API

I am using the fetch API to grab data from TMBD which I can display in the console like this...

fetch('https://api.themoviedb.org/3/movie/778?api_key=1234&append_to_response=videos,credits')
    .then(res => res.json())
    .then((out) => {
        console.log('Output: ', out);
}).catch(err => console.error(err));

The JSON looks like this...

{
"backdrop_path": "/8gSU1tLLdE5TWbcg9YDnR2lD0sO.jpg",
"belongs_to_collection": null,
"budget": 0,
"genres": [
    {
        "id": 99,
        "name": "Documentary"
    }
],
"homepage": "https://www.focusfeatures.com/roadrunner",
"id": 642732,
"imdb_id": "tt14512538",
"original_language": "en",
"original_title": "Roadrunner: A Film About Anthony Bourdain",
"overview": "An intimate, behind-the-scenes look at how an anonymous chef became a world-renowned cultural icon.",
"production_countries": [
    {
        "iso_3166_1": "US",
        "name": "United States of America"
    }
]

}

I now need to drop this into some simple HTML. For example, some variables that are named 'original_title' and 'overview', each in their own div...

<div>title outputs here</div>
<div>overview outputs here</div>

I know this is very simple, but I can't get the JS to work. Any help appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is a sample code for your reference.

let out={
  "adult": false,
  "backdrop_path": "/fCayJrkfRaCRCTh8GqN30f8oyQF.jpg",
  "belongs_to_collection": null,
  "budget": 63000000,
  "genres": [
    {
      "id": 18,
      "name": "Drama"
    }
  ],
  "homepage": "",
  "id": 550,
  "imdb_id": "tt0137523",
  "original_language": "en",
  "original_title": "Fight Club",
  "overview": "A ticking-time-bomb insomniac and a slippery soap salesman channel primal male aggression into a shocking new form of therapy. Their concept catches on, with underground \"fight clubs\" forming in every town, until an eccentric gets in the way and ignites an out-of-control spiral toward oblivion.",
  "popularity": 0.5,
  "poster_path": null
};

function go(){
  let overViewDiv=document.getElementById("overViewDiv");
  let originalTitleDiv=document.getElementById("originalTitleDiv");
  
  overViewDiv.innerHTML=out.overview;
  originalTitleDiv.innerHTML=out.original_title;
}
Over View:
<div id="overViewDiv"></div>
Original Title:
<div id="originalTitleDiv"></div>
<button onclick="go()">Go</button>

In your case,

  1. Set the id for each div as the sample code.

  2. And replace :

     console.log('Output: ', out);
    

    with :

       let overViewDiv=document.getElementById("overViewDiv");
       let originalTitleDiv=document.getElementById("originalTitleDiv");
    
       overViewDiv.innerHTML=out.overview;
       originalTitleDiv.innerHTML=out.original_title;
    
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda