The following code successfully retrieves the json from this API url, however if I try to access, say the status I can't return it at the same time as the retrieved data.
I would love to understand fetch a bit better. You can see my attempt as a comment.
const url = 'https://randomuser.me/api/?results=10';
fetch(url)
.then((resp) => {
status = resp.status;
responsejson = resp.json();
console.log( responsejson );
return responsejson;
//return {"status":status, "responsejson":responsejson} ;
})
.then(function(data) {
console.log( data );
})
.catch(function(error) {
console.log(error);
});