I'm trying to find out if a record was kept. From one function I call another to save the record, the problem is the asynchronous request of the second function. To solve it use promises, but I still have the problem of asynchronous when I invoke the promise I can get solved perfectly but my main function does not set the value to the variable isStepValid synchronize.
enterprise.save = function(element){
//some code...
   return new Promise((resolve ,reject) => {
    // .... request service 
     if(response.data[0].status == "SUCESS"){
               resolve(response.data[0].message);
     }
     else{
         reject(response.data[0].message);
      }
  });
}
function validateSteps(stepnumber){ 
var isStepValid = true;
        message="";
                enterprise.save(this).then((resolve)=>{
                isStepValid = true;
                console.log("resolve:",resolve);
                }).catch((reject)=>{
                console.log("reject:",reject);
                isStepValid = false;
                });
}
When this function is finished the variable isStepValid does not match the one of the answer of the promise (It agrees until after executing this function).
 
    