Answer the question
In order to leave comments, you need to log in
How to get link by api?
Friends help me deal with api! I need to get a link to the trailer
. I do it like this, but it doesn't work.
const API_KEY = "a1979074-3a11-448a-b2d2-55d1bb97cdf4";
const API_URL_VIDEOS = "https://kinopoiskapiunofficial.tech/api/v2.1/films/1236634/videos";
getMovies(API_URL_VIDEOS);
async function getMovies(url) {
const resp = await fetch(url, {
headers: {
"content-Type": "application/json",
"X-API-KEY": API_KEY,
},
});
const respData = await resp.json();
showMovies(respData);
}
function showMovies(data) {
const moviesEl = document.querySelector(".movies");
data.trailers.forEach((movie) => {
const movieEL = document.createElement("div");
movieEl.classList.add("movie");
movieEl.innerHTML = '<iframe id="ytplayer" type="text/html" width="100%" height="405" src="${movie.url}" frameborder="0" allowfullscreen></iframe>'
;
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question