From 90d981b2a40095d7fd29111166f5ae2d2c102433 Mon Sep 17 00:00:00 2001 From: Jonathan Putney Date: Mon, 29 Jun 2020 15:58:40 -0400 Subject: [PATCH] Fixing content type for sendBeacon --- src/BaseAPI.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/BaseAPI.js b/src/BaseAPI.js index 7336a62..abf5d55 100644 --- a/src/BaseAPI.js +++ b/src/BaseAPI.js @@ -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;