Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
¿Cómo almaceno la URL JSON en la variable JS y cargo el video en la página HTML?

Soy nuevo en HTML, JS y JSON y tengo problemas para cargar una URL de video desde un archivo JSON. Descargué el archivo JSON dehttps://ign-apis.herokuapp.com/videos?startIndex=30&count=5 . Cuando uso console.log(data.data[0].assets[4].url), muestra la URL correcta y puedo ver el video en la nueva ventana, pero parece que no puedo hacerlo. mostrar y ejecutar en mi página html.

índice.html

 <video width="1100px" height="555px" poster id="firstthumbnail"> <source src id="firstvid" type="video/mp4"> <!--First video--> </video> <script src="script.js"></script>

guión.js

 fetch("videos.json") .then(response => response.json()) .then(data => { console.log(data) document.querySelector("#firstvid").innerText = data.data[0].assets[4].url document.querySelector("#firstthumbnail").innerText = data.data[0].thumbnails[0].url })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

la propiedad innerText de un elemento decide qué se muestra como texto en el elemento. En lugar de usar .innerText , use .src .

about 4 years ago · Juan Pablo Isaza Report

0

Debe establecer el atributo src en su etiqueta de video. Prueba esto:

 document.getElementById("firstvid").setAttribute("src", data.data[0].assets[4].url);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!