Last active
February 18, 2018 13:29
-
-
Save lawvs/06490b1f3a6b499a13f8ac372b61a419 to your computer and use it in GitHub Desktop.
js发送异常日志
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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