I know the problem is the data.map.
Maybe its because map is made for arrays and i have an array of objects and not a array?
API-Response:
[
{
"id": 16,
"nachname": "Köpper",
"vorname": "Chris",
"projectList": []
},
{
"id": 13,
"nachname": "Kämpfer",
"vorname": "Gerrit",
"projectList": [
{
"id": 9,
"name": "FB.de"
},
{
"id": 7,
"name": "DFBnet"
}
]
},
{
"id": 12,
"nachname": "Voges",
"vorname": "Arved",
"projectList": [
{
"id": 9,
"name": "FB.de"
},
{
"id": 7,
"name": "DFBnet"
}
]
}
]
HTML-Table:
<table class="table" id="output1">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Vorname</th>
<th scope="col">Nachname</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
js:
function getPerson(){
fetch(url)
.then(res => res.json())
.then(data => {
var tableContent = document.querySelector('#output1 > tbody');
data.map(function(instance) {
const row = document.createElement('tr');
tableContent.appendChild(row);
instance.map(function(info) {
const cell = document.createElement('td');
cell.innerText = info;
row.appendChild(cell);
});
});
})
}