Skip to content

Commit

Permalink
JavaScript Client
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk Adamczyk committed Oct 23, 2019
1 parent 2f9222c commit f746344
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions client/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function log(base_url, trace = false, variable = {}) {
return new Promise((resolve, reject) => {
let data = variable;
if (trace) {
const err = new Error();
data = {
_var: variable,
_trace: err.stack,
};
}
let xhr = new XMLHttpRequest();
xhr.open('POST', `${base_url}/logger`);
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
xhr.send(JSON.stringify(data));
xhr.onload = resolve;
xhr.onerror = reject;
});
}

0 comments on commit f746344

Please sign in to comment.