const renderTableFromJSON = (parent, jsonObj) => {
const tableConstruct = json => {
let tableElement = '
';
for (const row in json) {
tableElement += `
${row} |
${json[row]} |
`;
}
tableElement += '
';
return tableElement;
}
fetch(`${jsonObj}`)
.then(response => response.json())
.then(luke => {
parent.insertAdjacentHTML('beforeend', tableConstruct(luke));
});
}
renderTableFromJSON(document.body, 'https://swapi.dev/api/people/1/');