javascript - Navigator.sendBeacon() to pass header information -


i using navigator communicating server , problem need pass header information there filter recognise request valid source.

can on this?

thanks.

@vipul panth has helpful information, wanted provide more complete details.

first, note navigator.sendbeacon not supported in browsers. see more detail function supported browsers @ mdn documentation.

you indeed create blob provide headers. here example:

window.onunload = function () {   let body = {     id,     email   };   let headers = {     type: 'application/json'   };   let blob = new blob([json.stringify(body)], headers);   navigator.sendbeacon('url', blob); }); 

navigator.sendbeacon send post request content-type request header set whatever in headers.type. seems header can set in beacon though, per w3c:

the sendbeacon method not provide ability customize request method, provide custom request headers, or change other processing properties of request , response. applications require non-default settings such requests should use [fetch] api keepalive flag set true.

i able observe of how worked through chromium bug report.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -