I've this piece of code
window.onbeforeunload = function (evt) {
//angular $http object
Rest.putInteraction({id:1}).then(function(){
//authorize the event to close window
});
};
Javascript of course doesn't wait for the rest call to start, and simply let the page unload at the end of the callback; so I cannot make the request I need beofre the page get unloaded.
Is there any way to pause the event callback and wait for the rest promise
to resolve?