Question: I've been really intrigued about `async / await` syntax recently and I've been experimenting with it for a while.  

In this particular problem, my goal is to execute the callback function after all the promises are made, if possible. 

I had no idea how to apply my ideas in real life situations so I expected the function to look like this. 

```js

function endTask (task) {
   // finalizes tasks 
}

var taskCompleted = false; 

async function doSomething (callback) {
   const response = await fetch(some_url);
   const task = await response.json(); 

    if (task) { 
     taskCompleted = true; 
    }
   if (typeof callback == "function" && taskCompleted) {
   callback(task); 
}
}

doSomething(endTask); 

```

Answer: 
I think if you already used async/await, maybe you don't need to use callback anymore. The purpose of async/await functions is to simplify the behavior of using promises, and avoid callback hell too.

Hope the example below could help.

```js
function endTask (task) {
   // finalizes tasks 
}

async function doSomething (callback) {
   const task = await fetch(some_url).then(res => res.json())；
   return task;
}

async function main() {
  const task = await doSomething();
  if (task) { 
    endTask()
  }
}

```
Yes, `async` functions can take and call callbacks just like any other function, but that pretty much defeats the purpose of using an `async` function. There are some cases where there is a valid reason to do this (see Dave Newton's comment below), but this isn't one of them.

Instead, you should do something like this:

```
function endTask(task) {
  // finalizes tasks 
}

var taskCompleted = false;

async function doSomething() {
  const response = await fetch(some_url);
  const task = await response.json();

  return task;
}

doSomething()
    .then(task => {
        if (task) {
            taskCompleted = true;
        }
        endTask(task);
    })
    .catch(error => {
        // handle error
    });  

```