I'm using Axios in a Vue app. I would like to send a request to my backend (to log the click of a button) but not wait for the response and then redirect the client to another page. Right now, the request is made, the redirect happens right away, and the initial request is 'cancelled' and my backend doesn't process the request.
I'd like to just fire off that request, then redirect AND NOT cancel the initial request. How can I do that?
Thanks all for the comments. Seems sendBeacon seems like it's been nerfed as you cannot send application/json for content type, and it this article says it is not reliable. So I used the following solution in my Vue component:
onClickLink: async function () {
var img = new Image()
img.src = `/my/path/to/controller/${this.$route.params.id}`
window.location.href = externalLinksFile.new_url
}