New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fishingrod

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fishingrod

Very small http request lib

latest
npmnpm
Version
4.1.1
Version published
Maintainers
1
Created
Source

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.

ParameterTypeDescription
httpsBooleanSets https: or http: as the protocol
methodStringSets the method for the request. All usual HTTP methods are accepted (GET, POST, PUT, DELETE ...). MUST BE uppercase
hostStringThe host for the request. Ex: api.google.com
pathStringThe 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)
dataString or ObjectThe data to send to the server. If the data is an object, it will be JSON.stringifyed for you.
headersObjectA collection of headers for the request. Ex: {'Content-Type':'application/json', 'X-My-Header': 'something custom'}
parseBooleanIf the response contains header Content-Type: application/json it will be JSON.parsed before giving you control of the answer
redirBooleanIf the response is a 3xx Http code and contains Location: header, will automatically redirect before giving you control
encodingStringSets the encoding for the response. Default is 'utf8'
debugBooleanSets the debug option, logging errors and every request
joinCharIf 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
separatorCharIf 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'});

Keywords

fishing

FAQs

Package last updated on 03 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts