Posted on September 6, 2019 at 9:53 am
Here is an example of using NodeJs “request” library with error handling:
var dateformat = require('dateformat'); var request = require('request'); request.get('https://www.google.com/',function(err, res, body) { if(err) console.error('[Request.Get] %s Error:', dateformat(new Date(), "yyyy-mm-dd h:MM:ss"), err.message); console.log('[Request.Get] %s StatusCode:', dateformat(new Date(), "yyyy-mm-dd h:MM:ss"), res.statusCode); }); |
It should output something like this:
[Request.Get] 2019-09-06 9:45:07 StatusCode: 200 |
Other Posts
- Set OpenVPN to Listed on a Specific IP Address
- Bash Trim Leading and Trailing Whitespace from a String
- Bash Get Name of Ethernet Network Interface
- VPN Providers with Dedicated Static IP Address
- OpenVPN Iptables Rules
- WireGuard VPN Iptables Rules
- How to Install WireGuard VPN in Debian 10 Buster
- Bash: No space left on device (inodes issue)
Updated Posts
- Add Desktop shortcut for all Windows PC users
- How to pass custom command-lien parameters in InnoSetup
- Programmatically create desktop icon with InnoSetup
- GeneratePress - a Lightweight WordPress Theme 2021
- InnoSetup disable DesktopIcon via command-line
- Use cURL to authenticate with JWT Bearer tokens
- Detect VMWare Virtual Machine
- Detect Microsoft Virtual PC Virtual Machine