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 {
try {
let beacon;
const headers = {
type: this.settings.commitRequestDataType,
};
let blob;
if (params instanceof Array) {
beacon = navigator.sendBeacon(url, params.join('&'));
blob = new Blob([params.join('&')], headers);
} else {
beacon = navigator.sendBeacon(url, params);
blob = new Blob([JSON.stringify(params)], headers);
}
result = {};
if (beacon) {
if (navigator.sendBeacon(url, blob)) {
result.result = global_constants.SCORM_TRUE;
} else {
result.result = global_constants.SCORM_FALSE;