1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Http utilities: add xhr object to callback

This commit is contained in:
Jermolene 2019-04-15 21:07:23 +01:00
parent 04a4a0f92e
commit 232eba2f7d

View File

@ -17,7 +17,7 @@ A quick and dirty HTTP function; to be refactored later. Options are:
url: URL to retrieve
headers: hashmap of headers to send
type: GET, PUT, POST etc
callback: function invoked with (err,data)
callback: function invoked with (err,data,xhr)
returnProp: string name of the property to return as first argument of callback
*/
exports.httpRequest = function(options) {
@ -48,7 +48,7 @@ exports.httpRequest = function(options) {
return;
}
// Something went wrong
options.callback($tw.language.getString("Error/XMLHttpRequest") + ": " + this.status);
options.callback($tw.language.getString("Error/XMLHttpRequest") + ": " + this.status,null,this);
}
};
// Make the request
@ -67,7 +67,7 @@ exports.httpRequest = function(options) {
try {
request.send(data);
} catch(e) {
options.callback(e);
options.callback(e,null,this);
}
return request;
};