I can not get the title in JavaScript from my API. I want to display the title in HTML.
api:(https://k0wa1un85b.execute-api.us-east-1.amazonaws.com/production/books)
JSON response looks like:
{"statusCode":200,"body":[{"id":"4f160b1f8693cdbeb96ac8be135ff0f9","title":"Harry Potter"}]}
javascript:
<body>
<p>
title: <span id="tit"></span><br/>
</p>
<script>
const api_url = 'https://k0wa1un85b.execute-api.us-east-1.amazonaws.com/production/books';
async function getISS() {
const response = await fetch(api_url);
const data = await response.json();
console.log(data);
const {title} = (data);
document.getElementById('tit').textContent = title;
}
getISS();
</script>
</body