Check if the website is accessible

I want to check if a particular website is available. The website name comes from the input field and is sent via message.

There is an NPM module for ping hosts, but that doesn't help me much. I need a solution for checking URL with parameters, for example: hostname.com/category

I would be grateful for the suggestions.

+5
source share
1 answer

Just make an HTTP request.

 var http = require('http'); http.get('http://example.com/category', function (res) { // If you get here, you have a response. // If you want, you can check the status code here to verify that it `200` or some other `2xx`. }).on('error', function(e) { // Here, an error occurred. Check `e` for the error. });; 
+8
source

Source: https://habr.com/ru/post/1208495/


All Articles