Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including u2r with all npm packages installed. Try it out:

var u2r = require("u2r")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

u2r v0.1.3

url to request info

[node.js] make an option object for "http(s).request" from url.


OK, node-request is really easy to use, but I wanted only the simplest function to get options object to pass to http(s)Client from url.


git clone git://


npm install u2r


var u2r = require('u2r');
var options = u2r('', {}); // second argument is optional.
var protocol = require(options.protocol);
var req = require('http').request(option, function(res) {
  res.on('data', function(d) {
    // do something

specific options

  • protocol : http or https

  • body : if method != "GET", querystring of is set. is passed by u2r(url, here)

  • all other options are compatible with the one http(s)Clients specify.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free