Created
January 8, 2019 13:23
-
-
Save PoOwAa/85c7251632d26ce9379103a93cae1916 to your computer and use it in GitHub Desktop.
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
const qs = "http://notworkingurl.com"; | |
fetch(qs) | |
.then(response => { | |
return response.json(); | |
}) | |
.then(data => { | |
// Working code | |
console.log(data); | |
}) | |
.catch(error => { | |
console.error("######## I GOT ONE ########"); | |
console.error(error); | |
const myLoggerUrl = "http://example.com/"; | |
fetch(myLoggerUrl, { | |
method: "POST", | |
mode: "cors", | |
cache: "no-cache", | |
credentials: "same-origin", | |
headers: { | |
"Content-Type": "application/json" | |
}, | |
redirect: "follow", | |
referrer: "no-referrer", | |
body: JSON.stringify(error) | |
}) | |
.then(response => { | |
return response.json(); | |
}) | |
.then(data => { | |
console.log("Log sent successfully!"); | |
}) | |
.catch(error => { | |
console.error("######## I GOT ONE ########"); | |
console.error("Logger server is not available"); | |
console.error(error); | |
// Esetleg itt localStorage-be helyezni vagy bármi | |
}); | |
}); |
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
<html> | |
<head> | |
<script src="./catchError.js"></script> | |
<title>Error küldő izébizé</title> | |
</head> | |
<body> | |
Error küldő izébizé | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment