Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

reachy-url

shivamjoker21AGPL31.1.0TypeScript support: included

Zero dependency nodejs library for checking if URL is reachable or not

domain-check, url-resolver, url, url-exist, url-validator

readme

reachy-url

Zero dependency nodejs library for checking if URL is reachable or not

Installation

pnpm install reachy-url
yarn add reachy-url
npm install reachy-url

How to use?

Functions

default

default(url, timeout?, requestOptions?): Promise<string | number | Error>

Check if a URL is reachable

Example

try {
  const statusCode = await isReachable("https://learnaws.io");
  // statusCode = 200
} catch (error) {
  const { message } = error;
  // Unable to resolve given URL, got status 404 or
  // Request timed out while requesting the provided URL
}

Parameters

Name Type Default value Description
url string undefined URL of the website
timeout number 2000 Cancel request after given time
requestOptions? RequestOptions undefined Request options for HTTP Request

Returns

Promise<string | number | Error>

Promise object with status code or error

Defined in

index.ts:24