Vipul Panth Vipul Panth - 9 days ago 6
Javascript Question

Navigator.sendBeacon() to pass header information

I am using navigator for communicating with the server , but problem is that we need to pass some header information as there is filter which recognise the request is from the valid source.

Can anybody help on this?

Thanks.

Answer

After searching for an answer for this question i found out that for passing header with navigator we need to pass a blob object.

For example

var hearders = {type : 'application/json'};
var blob = new blob(request , headers);
navigator.sendBeacon('url/to/send',blob);

Thanks.

Comments