Cancel request before it is sent
See original GitHub issueIs it possible to cancel an action before the corresponding HTTP request is sent?
From the readme, here’s what we have to work with before a message is sent.
gmail.observe.before('send_message', function(url, body, data, xhr){ }
I was thinking it might be possible to cancel the xhr request, but it hasn’t even been sent yet.
The use case it to perform a check and prompt the user for confirmation if certain conditions are met.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13
Top Results From Across the Web
How do I cancel a friend request I sent to someone ... - Facebook
To cancel a friend request you sent: 1. Go to your Sent Friend Requests. 2. Tap Cancel next to a friend request to...
Read more >I made a Facebook friend request. First it said cancel ... - Quora
“cancel request” it means you can cancel your friend request, “request” means your requested person has denied your request now you can send...
Read more >How to Cancel a Request in JavaScript - Level Up Coding
The XMLHttpRequest.abort() method aborts the request if it has already been sent. When a request is aborted, its readyState is changed to XMLHttpRequest....
Read more >Automatically Canceling Previous Requests in JavaScript
This way, each request will be automatically canceled when a new one of the same type is made. This is what happens in...
Read more >How to Cancel Sent Friend Requests on Facebook - YouTube
When you send a Friend Request on Facebook, you need to wait for the other person to accept it until you can view...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for the suggestions. I considered hooking into the click event, but I didn’t know how to get the list of email addresses from the To, CC, and BCC fields. Looking at the API a bit more though, I now see there’s a
recipient_changeevent that does just that.I’m a bit confused about the documentation though:
I’m not sure what “match” refers to. From experimenting in the console it appears to be a large DOM element holding everything but the header in the compose dialog. I’m guessing this is in order to find this element in the DOM tree in order to track down which compose dialog it came from?
Actually, with this event handler, maybe I don’t even need to intercept a click–just change some styling or something as a warning.
Anyway, thanks so much for the help! Much appreciated. 😄
Thanks. I may investigate that route. I also just discovered the
abort()method on thexhrobject. Just experimenting in the console it appeared aborting it before it was sent would keep it from being sent at all (as long as it wasopen()ed before beingabort()ed). It’s looking promising