I have a problem with using fetchs, I have an array of urls that have a JSON content, I want to get the data from all these JSON's and display them in html.
With 1 url I get the result I want:
fetch('myurl1')
.then(response => response.json())
.then(data => {
let element = document.querySelector('.ele');
element.innerHTML = `<p>${data.title}</p>`
})
.catch(err => console.log(err))
But when I have several urls I do not know what to do, I want to display the title that it has in all these json files, how do?
Promise.all(urlsArray.map(url =>
fetch(url)))
.then(responses => {
responses.forEach(response => {
response.json();
let element = document.querySelector('.ele');
element.innerHTML = `<p>${?????.title}</p>`
})
})
.catch(err => console.log(err))
This is the way I was trying, I do not know how.
PS: .ele is a div