< P> Я пытался использовать функцию Map . Все работает помимо вложенного массива. < /P>
Это выход в журнале консоли: < /p>
.
Код: Выделить всё
document.querySelector("button").addEventListener("click", fetchGetSuper)
function fetchGetSuper() {
const superChoice = document.querySelector("input").value
const imageSize = "standard_fantastic"
const items = [];
fetch(`http://gateway.marvel.com/v1/public/characters?name=${superChoice}&ts=1&apikey=...&hash=fb9c86270d3aabd34201984d2f77cfe6`)
.then(response => {
if (!response.ok) {
throw Error("ERROR");
}
return response.json();
})
.then(data => {
console.log(data.data.results);
var html = data.data.results.map(comic => {
return `
Name: ${comic.name}
Description: ${comic.description}
[list]
[*]
${comic.urls}
[/list]
`;
})
.join("")
console.log(html);
document.querySelector(`#cards`).insertAdjacentHTML("afterbegin", html);
})
.catch(error => {
console.log(error);
});
}< /code>
Get a Marvel
Подробнее здесь: https://stackoverflow.com/questions/794 ... while-usin
Мобильная версия