Add a requestHandler setting to BaseAPI.
It mirrors `responseHandler` and it's useful for the same reason: to be able to adapt the data sent to the LMS.
This commit is contained in:
@@ -62,6 +62,7 @@ The APIs include several settings to customize the functionality of each API:
|
||||
| `xhrWithCredentials` | false | true/false | Sets the withCredentials flag on the request to the LMS |
|
||||
| `xhrHeaders` | {} | Object | This allows setting of additional headers on the request to the LMS where the key should be the header name and the value is the value of the header you want to send |
|
||||
| `responseHandler` | function | | A function to properly tranform the response from the LMS to the correct format. The APIs expect the result from the LMS to be in the following format (errorCode is optional): `{ "result": true, "errorCode": 0 }` |
|
||||
| `requestHandler` | function | | A function to transform the commit object before sending it to `lmsCommitUrl`. By default it's the identity function (no transformation). |
|
||||
|
||||
## Initial Values
|
||||
|
||||
|
||||
7
dist/aicc.js
vendored
7
dist/aicc.js
vendored
File diff suppressed because one or more lines are too long
5
dist/aicc.min.js
vendored
5
dist/aicc.min.js
vendored
@@ -633,6 +633,9 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
requestHandler: function requestHandler(commitObject) {
|
||||
return commitObject;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1732,6 +1735,8 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
try {
|
||||
params = settings.requestHandler(params);
|
||||
|
||||
if (params instanceof Array) {
|
||||
httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
httpReq.send(params.join('&'));
|
||||
|
||||
7
dist/scorm-again.js
vendored
7
dist/scorm-again.js
vendored
File diff suppressed because one or more lines are too long
5
dist/scorm-again.min.js
vendored
5
dist/scorm-again.min.js
vendored
@@ -633,6 +633,9 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
requestHandler: function requestHandler(commitObject) {
|
||||
return commitObject;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1732,6 +1735,8 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
try {
|
||||
params = settings.requestHandler(params);
|
||||
|
||||
if (params instanceof Array) {
|
||||
httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
httpReq.send(params.join('&'));
|
||||
|
||||
7
dist/scorm12.js
vendored
7
dist/scorm12.js
vendored
File diff suppressed because one or more lines are too long
5
dist/scorm12.min.js
vendored
5
dist/scorm12.min.js
vendored
@@ -512,6 +512,9 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
requestHandler: function requestHandler(commitObject) {
|
||||
return commitObject;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1611,6 +1614,8 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
try {
|
||||
params = settings.requestHandler(params);
|
||||
|
||||
if (params instanceof Array) {
|
||||
httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
httpReq.send(params.join('&'));
|
||||
|
||||
7
dist/scorm2004.js
vendored
7
dist/scorm2004.js
vendored
File diff suppressed because one or more lines are too long
5
dist/scorm2004.min.js
vendored
5
dist/scorm2004.min.js
vendored
@@ -512,6 +512,9 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
requestHandler: function requestHandler(commitObject) {
|
||||
return commitObject;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1611,6 +1614,8 @@ var BaseAPI = /*#__PURE__*/function () {
|
||||
}
|
||||
|
||||
try {
|
||||
params = settings.requestHandler(params);
|
||||
|
||||
if (params instanceof Array) {
|
||||
httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
httpReq.send(params.join('&'));
|
||||
|
||||
@@ -48,6 +48,9 @@ export default class BaseAPI {
|
||||
}
|
||||
return result;
|
||||
},
|
||||
requestHandler: function(commitObject) {
|
||||
return commitObject;
|
||||
},
|
||||
};
|
||||
cmi;
|
||||
startingData: {};
|
||||
@@ -1114,6 +1117,7 @@ export default class BaseAPI {
|
||||
};
|
||||
}
|
||||
try {
|
||||
params = settings.requestHandler(params);
|
||||
if (params instanceof Array) {
|
||||
httpReq.setRequestHeader('Content-Type',
|
||||
'application/x-www-form-urlencoded');
|
||||
|
||||
Reference in New Issue
Block a user