An API lets one program ask another program for data or actions. Modern applications often depend on APIs to load information from services outside the app itself.
async function loadPosts(): Promise<void> {
const response = await fetch("https://jsonplaceholder.typicode.com/posts");
const posts = await response.json();
console.log(posts[0]);
}
loadPosts().catch((error) => {
console.error("Failed to load posts", error);
});