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 🙏

© 2024 – Pkg Stats / Ryan Hefner

fishingrod

v4.1.1

Published

Very small http request lib

Downloads

282

Readme

fishingrod

A simple module for making http requests, depends on nothing but http and https.

NOTE: this is not intended to be a full-featured http package, or a full-tested module. This is a simple, working http module, that permits very simple requests. Do not use in production without testing.

Simple Example

const fishingrod = require('fishingrod');

fishingrod.fish({
	https:true,
	host: 'example.com',
	path: '/obj/1'
},
function(err, st, res){
	console.log(res);
});

fishingrod.fish({
	https:true,
	host: 'example.com',
	path: '/obj/2'
}).then(function(res){
	console.log(res.response);
});

API

fishingrod works in a very simple way using different parameters. A simple request will typically use https, host, path, method and data & headers if needed.

Some more parameters are also available if you would ever need them, and direct url pasting (request style) is also applicable.

| Parameter | Type | Description | |:---------:|:----:|:------------| | https| Boolean | Sets https: or http: as the protocol| | method | String | Sets the method for the request. All usual HTTP methods are accepted (GET, POST, PUT, DELETE ...). MUST BE uppercase | | host | String | The host for the request. Ex: api.google.com | | path | String | The path for the request. Ex /api/v3.0/something?this=is&a=query (Query is optional, but for POST requests it won't be extracted from data)| | data | String or Object | The data to send to the server. If the data is an object, it will be JSON.stringifyed for you. | | headers| Object | A collection of headers for the request. Ex: {'Content-Type':'application/json', 'X-My-Header': 'something custom'} | | parse | Boolean | If the response contains header Content-Type: application/json it will be JSON.parsed before giving you control of the answer| | redir | Boolean | If the response is a 3xx Http code and contains Location: header, will automatically redirect before giving you control | | encoding | String | Sets the encoding for the response. Default is 'utf8' | | debug | Boolean| Sets the debug option, logging errors and every request | | join | Char | If using Object Data && Content-Type: application/x-www-form-urlencoded, will be used as the join char between key-value pairs. Ex: plep=56${join}plop=57 | | separator | Char | If using Object Data && Content-Type: application/x-www-form-urlencoded, will be used as the join char between each key and its value. Ex: plop${separator}56 |

Utility methods

You can also call fishingrod with only a url using the utility methods. These are .get, .post, .put, .delete, ._method. They all take (url [STRING], data[OBJECT], headers[OBJECT]) as params, except _method which takes (method, [STRING CAPITALS], url [STRING], data[OBJECT], headers[OBJECT]).

const fishingrod = require('fishingrod');

fishingrod.get('http://google.com', {query:'Bottomatik chatbots'}, {'Accept':'application/pdf'});