Created
October 8, 2021 00:03
-
-
Save deltastateonline/47c345bca56eb2b321b522364a658c47 to your computer and use it in GitHub Desktop.
Using Promises
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async republishRequest({dispatch,commit},payload) { | |
//console.log(dispatch); | |
//console.log(commit); | |
commit('SET_BUSY_RESPONSES',true); | |
commit('CLEAR_TO_REPUBLISHLIST'); | |
return new Promise((resolve, reject)=>{ | |
axios.post(endpoint.repub_prefix+"func_republish_events_http", payload).then(response=>{ | |
resolve(response) | |
}).catch(error =>{ | |
reject(error) | |
}) | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
republish(){ | |
var payload = { | |
'containerList': this.selected_containers, | |
'publishToLiveDashboards': this.publish_events, | |
'filterEvents' : this.selected_events | |
}; | |
var that = this; | |
that.publishing = true; // show the publishing spinner | |
// this is calling the method in the other file | |
republishRequest(JSON.stringify(payload)).then(()=>{ | |
that.startProcess = true; // used to start the polling | |
that.selected_containers = []; // reset the selected container list | |
that.publish_events = false; // reset the publish events to dashboard | |
that.selected_events = []; // reset the selected event filter list | |
that.publishing = false; // hide the publishing spinner | |
}).catch(rej=>{ | |
that.message = rej; | |
that.responseshow = true; // show the alerts with message | |
that.responsevariant = "danger"; // set the style to danger | |
that.startProcess = false; // used to clear inteval | |
that.publishing = false; // hide the publishing spinner | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment