asysn await in js code example
Example 1: async await
const data = async () => {
const got = await fetch('https://jsonplaceholder.typicode.com/todos/1');
console.log(await got.json())
}
data();
Example 2: async await
async function () {
const fetchAPI = fetch(`https://bn-hadith-api.herokuapp.com/hadiths/0`);
const response = await fetchAPI;
const data = await response.json();
console.log(data);
}