I want to render a list from an API but the problem is I am able to console.log the element I want to render but I am not able to render it into the HTML side below is the code.
when I use <li>${element}</li>
it gives an error.
const url1 = "https://jsonplaceholder.typicode.com/users/1"
const url2 = "https://jsonplaceholder.typicode.com/users/2"
const url3 = "https://jsonplaceholder.typicode.com/users/3"
const fData = document.getElementById('fData')
async function fetchApis() {
const results = await Promise.all([fetch(url1), fetch(url2), fetch(url3)])
const responseAll = results.map(result => result.json())
const finalData = await Promise.all(responseAll)
console.log(finalData)
const finalDataToString = finalData.map(function(arraydata) {
return arraydata.name
})
fData.innerHTML = `${finalDataToString.forEach(element => {
console.log(element)
})}`
}
fetchApis()
<ul id="fData"></ul>