npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

open-request-js

v1.0.35

Published

Simply send http requests.

Downloads

40

Readme

Open Request JS 📣

npm version Maintainability

Simply send http requests.

Install

npm install open-request-js

Usage

var Request = require('open-request-js'); // To be used from node.
var Request = require('open-request-js/dist'); // To be used from browser.

var request = new Request('/users/:id?lang=en');

request.url.path.id = 4;
request.url.parameters.lang = 'fr';
request.url.string;
// => "/users/4?lang=fr"

request.send().then(response => console.log(response.json));

Why does the require statement depend on wether it's meant to be use from node or from browser?

Because from node, Request needs to require XMLHttpRequest while it already exists in the browser. By the way, you will not be able to use html and xml HttpResponse accessors from node neither because (at the moment) they depend on browser-exclusive APIs.

Request

Kind: global class

new Request([url], [method], [data])

Creates a Request object.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [url] | string | Url | | The url of the request. | | [method] | string | "get" | The request method. | | [data] | Object | Parameters | | The data to send. |

request.method : string

The method of the request. When set it will be checked for being included in 'get', 'post', 'put', 'patch' and 'delete'. If not it will be replaced by 'get'.

Kind: instance property of Request

request.actualMethod : string

The actual method that will be used to send the request (wether 'get' or 'post').

Kind: instance property of Request
Read only: true

request.url : Url | string

The request url.

Kind: instance property of Request

request.data : Parameters | Object | string

The request data. When set it will be parsed to a Parameters object.

Kind: instance property of Request

request.send(data) ⇒ Promise

Sends the request, merging the given data with the instance data to a new object.

Kind: instance method of Request
Returns: Promise - A promise to resolved when the request finished and succeed, or to be rejected if any error occurs (including http errors). A HttpResponse object is always passed.

| Param | Type | Description | | --- | --- | --- | | data | Parameters | Object | string | The data to send, in addition to the instance data. |

Request.send(url, [method], [data]) ⇒ Promise

Sends a request.

Kind: static method of Request
Returns: Promise - A promise to resolved when the request finished and succeed, or to be rejected if any error occurs (including http errors). A HttpResponse object is always passed.

| Param | Type | Default | Description | | --- | --- | --- | --- | | url | string | Url | | The url of the request. | | [method] | string | "get" | The request method. | | [data] | Object | Parameters | | The data to send. |

Request.get(url, [data]) ⇒ Promise

Sends a get request.

Kind: static method of Request
Returns: Promise - A promise to resolved when the request finished and succeed, or to be rejected if any error occurs (including http errors). A HttpResponse object is always passed.

| Param | Type | Description | | --- | --- | --- | | url | string | Url | The url of the request. | | [data] | Object | Parameters | The data to send. |

Request.post(url, [data]) ⇒ Promise

Sends a post request.

Kind: static method of Request
Returns: Promise - A promise to resolved when the request finished and succeed, or to be rejected if any error occurs (including http errors). A HttpResponse object is always passed.

| Param | Type | Description | | --- | --- | --- | | url | string | Url | The url of the request. | | [data] | Object | Parameters | The data to send. |

Request.put(url, [data]) ⇒ Promise

Sends put get request.

Kind: static method of Request
Returns: Promise - A promise to resolved when the request finished and succeed, or to be rejected if any error occurs (including http errors). A HttpResponse object is always passed.

| Param | Type | Description | | --- | --- | --- | | url | string | Url | The url of the request. | | [data] | Object | Parameters | The data to send. |

Request.patch(url, [data]) ⇒ Promise

Sends patch get request.

Kind: static method of Request
Returns: Promise - A promise to resolved when the request finished and succeed, or to be rejected if any error occurs (including http errors). A HttpResponse object is always passed.

| Param | Type | Description | | --- | --- | --- | | url | string | Url | The url of the request. | | [data] | Object | Parameters | The data to send. |

Request.delete(url, [data]) ⇒ Promise

Sends a delete request.

Kind: static method of Request
Returns: Promise - A promise to resolved when the request finished and succeed, or to be rejected if any error occurs (including http errors). A HttpResponse object is always passed.

| Param | Type | Description | | --- | --- | --- | | url | string | Url | The url of the request. | | [data] | Object | Parameters | Parameters | The data to send. |

HttpResponse

Kind: global class

new HttpResponse([data], [status])

Creates a HttpResponse object.

| Param | Type | Description | | --- | --- | --- | | [data] | string | The data of the response. | | [status] | Status | Object | The status of the response. |

httpResponse.status : Status | Object

The response status. When set, it will be parsed to a Status object

Kind: instance property of HttpResponse

httpResponse.text : string

The response in text format.

Kind: instance property of HttpResponse

httpResponse.json : Object

The response in json format.

Kind: instance property of HttpResponse

httpResponse.xml : Element

The response in XML format.

Kind: instance property of HttpResponse

httpResponse.html : Element

The response in HTML format.

Kind: instance property of HttpResponse

Status

Kind: global class

new Status([code], [text])

Creates a Status object.

| Param | Type | Description | | --- | --- | --- | | [code] | number | string | The code of the response. | | [text] | string | The text of the response. |

status.code : number | string

The code of the response. When set, it will be parsed to an integer, and set to 0 if it's invalid.

Kind: instance property of Status

status.text : string

The text of the response.

Kind: instance property of Status

status.info : boolean

Tells if this is an info.

Kind: instance property of Status

status.success : boolean

Tells if this is a success.

Kind: instance property of Status

status.redirection : boolean

Tells if this is a redirection.

Kind: instance property of Status

status.error : boolean

Tells if this is an error.

Kind: instance property of Status

status.set([code], [text])

Set the status

Kind: instance method of Status

| Param | Type | Description | | --- | --- | --- | | [code] | number | string | The code of the response. | | [text] | string | The text of the response. |

Classes