Skip to content

Instantly share code, notes, and snippets.

@lawvs
Last active February 18, 2018 13:29
Show Gist options
  • Save lawvs/06490b1f3a6b499a13f8ac372b61a419 to your computer and use it in GitHub Desktop.
Save lawvs/06490b1f3a6b499a13f8ac372b61a419 to your computer and use it in GitHub Desktop.
js发送异常日志
window.addEventListener('error', function (e) {
const stack = e.error.stack;
let message = e.error.toString();
if (stack) {
message += '\n' + stack;
}
const xhr = new XMLHttpRequest();
xhr.open('POST', '/log', true);
xhr.send(message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment