I'm learning promises in Angular.
I have this function:
  myFunction(): Promise<any> {
    return new Promise(resolve => {
      resolve(this.cognitoUtil.updateAtributes(this.id, this.userProfileForm));
    });
  }
Inside of the method cognitoUtil.updateAtributes, there are a methods that are called and I have the log console.log("callback") after the methods are executed:
updateAtributes(id: string, user: UserForm) {
const cognitoUser = this.getCurrentUser();
cognitoUser.getSession(function (err, session) {
  if (err) {
    return;
  }
  const attributeList = [];
  const dataName = {
    Name: 'name',
    Value: user.name
  };
  const dataEmail = {
    Name: 'email',
    Value: user.email
  };
  attributeList.push(new CognitoUserAttribute(dataName));
  attributeList.push(new CognitoUserAttribute(dataEmail))
  cognitoUser.updateAttributes(attributeList, function (error, result) {
    if (error) {
      alert(err);
      return;
    }
    console.log("callback");
  });
});
} 
The promise is called in this way:
this.myFunction().then(() => console.log('Inside the promise'));
When the promise is called, the log inside the promise appears before the log callback:
Why is it happening that? How can I do to have the log Inside the promise after the log callback.

 
     
     
    