I want to see the json obtained from a url in html inside a tag with id code, but since it is an asynchronous function what I get is an [object Promise] and in the console I get the json.
let prueba = 'https://nominatim.openstreetmap.org/reverse?lat=41.63125237270472&lon=-4.742565007934635&format=json';
async function load() {
let url = prueba;
let obj = null;
try {
obj = await (await fetch(url)).json();
} catch (e) {
console.log('error');
}
console.log(obj);
return obj;
}
load();
document.getElementById('codigo').innerHTML = load();;
Put it inside the function like this: