Fixing content type for sendBeacon

This commit is contained in:
Jonathan Putney
2020-06-29 15:58:40 -04:00
parent 8b58992293
commit 90d981b2a4

View File

@@ -950,15 +950,18 @@ export default class BaseAPI {
} }
} else { } else {
try { try {
let beacon; const headers = {
type: this.settings.commitRequestDataType,
};
let blob;
if (params instanceof Array) { if (params instanceof Array) {
beacon = navigator.sendBeacon(url, params.join('&')); blob = new Blob([params.join('&')], headers);
} else { } else {
beacon = navigator.sendBeacon(url, params); blob = new Blob([JSON.stringify(params)], headers);
} }
result = {}; result = {};
if (beacon) { if (navigator.sendBeacon(url, blob)) {
result.result = global_constants.SCORM_TRUE; result.result = global_constants.SCORM_TRUE;
} else { } else {
result.result = global_constants.SCORM_FALSE; result.result = global_constants.SCORM_FALSE;