feat(async-await): catch promise with then() NOT working

This commit is contained in:
dancingCycle 2023-12-04 14:36:40 +01:00
parent c291026248
commit 5a66948cb7
1 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,4 @@
function fetchDataFromApi() {
async function fetchDataFromApi() {
console.log('fetchDataFromApi() start...');
fetch('https://v2.jokeapi.dev/joke/Programming?type=single')
@ -8,5 +8,6 @@ function fetchDataFromApi() {
console.log('fetchDataFromApi() done.');
};
fetchDataFromApi()
console.log('index: Finished fetching data.');
fetchDataFromApi().then(() => {
console.log('Finished fetching data');
});