Skip to main content

One post tagged with "fetch"

View All Tags

ยท One min read
Kumar Nitesh
// fetching data from an API with basic promise syntax (notice the use of arrow functions)window  .fetch("")  .then((response) => response.json())  .then((data) => console.log(data));
// fetching same data from API with async/await    async function getPostData() {         const response = await window.fetch( "" );        // we need to resolve two promises using await to get the final data         const data = await response.json();         console.log(data);     }     getPostData();