var isError = false;
savedata.ingredients.split(',').reduce(function(p, ing) {
      return p.then(function() {
            return db.dog_ingredients.create({ content_name: ing, dogFoodId: dogId });
      });
}, Promise.resolve()).catch(function(e) {
      console.log(e);
      isError = true; ///// I want to change value at this point
});
console.log(isError); // result false. 
if(isError){
  res.status(400).send('Error');
}else{
  res.status(200).send('Good');
}
I think that external variable didn't change because promise is done asynchronously. but I don't know how to solve this problem.
 
     
     
    