google-apps-scriptcallbackasynccallbackmultiple-arguments

Can I pass multiple callback function inside withSuccessHandler?


This is the code i am running

document.addEventListener('DOMContentLoaded', function() {
google.script.run.withSuccessHandler(populateSearchDropDown).searchByVehicleNum();
});

now my question is , Can i pass 2 callback functions inside withSuccessHandler?

something like this

google.script.run.withSuccessHandler(function1,function2).scriptFunc();

BTW I tried that and its not working


Solution

  • In that case, how about the following modification?

    From:

    google.script.run.withSuccessHandler(function1,function2).scriptFunc();
    

    To:

    google.script.run.withSuccessHandler(sample).scriptFunc();
    
    function sample(e) {
      function1(e);
      function2(e);
    }
    

    or

    google.script.run.withSuccessHandler(e => {function1(e), function2(e)}).scriptFunc();
    

    Reference: