Fetching a JSON file across the network and printing it to the console
<div id="posts">...</div>
<script>
const API = 'https://';
const postElement = document.querySelector('#posts');
let page = 0;
fetch(`${API}/posts`)
.then(response => {
return response.json();
})
.then(posts => {}
})
.catch(error => console.error(error));
</script>
Top comments (0)