healthchecks/templates/docs/javascript.md
2020-12-28 14:06:54 +02:00

20 lines
463 B
Markdown

# Javascript
Below is an example of making an HTTP request to SITE_NAME from Node.js.
```js
var https = require('https');
https.get('PING_URL').on('error', (err) => {
console.log('Ping failed: ' + err)
});
```
You can also send pings from a browser environment. SITE_NAME sets the
`Access-Control-Allow-Origin:*` CORS header, so cross-domain AJAX requests work.
```js
var xhr = new XMLHttpRequest();
xhr.open('GET', 'PING_URL', true);
xhr.send(null);
```