hyperrequest
v0.1.4
Published
A wrapper arround hyperquest to handle the results
Downloads
39
Readme
hyperrequest
A wrapper arround hyperquest to handle the results
Install
npm install hyperrequest
Usage
Basic example
var hrrequest = require( "hyperrequest" );
hrrequest( { url: "http://www.exapme.com" }, function( err, resp ){
/*handle response*/
});
Detailed example
var hrrequest = require( "hyperrequest" );
var opts = {
url: "http://www.myapi.com/path/api/v1", // The path to request including `http://`. Alternative keys : `uri` or `path`
method: "POST", // http method
headers: { // http headers object
"Content-type": "application/json"
},
json: { "foo": 23, "bar": [ 42, "buzz" ] }, // Only relevant for method `POST, `PUT` or `PATCH`. This will be stringified before transmission.
body: "ABC" // // Only relevant if `json` is not defined and for method `POST, `PUT` or `PATCH`.
};
hrrequest( opts, function( err, resp ){
if( err ){
// handle the error
return
}
// the result is a regular node-js response object.
console.log( resp.body ) // The result will be placed inside `body`. If the content-type is `application/json` it tries to parse it and returns the parsed data
});
Options
- url : (
String
required ) The path to request includinghttp://
. Alternative keys :uri
orpath
- method : (
String
optional: default =GET
; ) The http method - headers : (
Object
optional ) The http headers object - json : (
Any
optional ) JSON data to send. This will be stringified and used as body before transmission. Only relevant for methodPOST,
PUTor
PATCH`. - body : (
String|Buffer
optional ) Body data to send. Only relevant ifjson
is not defined and for methodPOST,
PUTor
PATCH`. - auth : (
Object
optional ) Add an basic header authentication.- auth.(user|username) : (
String
) The username for the authentication. - auth.(pass|password) : (
String
) The password for the authentication.
- auth.(user|username) : (
Todos
- more Tests ;-)
Release History
|Version|Date|Description| |:--:|:--:|:--| |0.1.4|2017-09-11|fixed dev dependency version | |0.1.3|2017-09-11|fixed another bug when receiving an empty or defect content-type;| |0.1.2|2017-01-19|fixed bug when receiving no content-type; Updated and optimized dev env.| |0.1.1|2016-05-25|fixed handling of empty content 204| |0.1.0|2016-05-12|Added option to use basic auth. Updated dependencies and dev environment with docker tests for a list of node versions, removed Code docs from repository| |0.0.4|2015-12-01|removed deprecated dependency; added code docs| |0.0.3|2015-11-30|Bugfixes; Optimizations; Added tests; Added docs| |0.0.2|2015-11-27|Small bugfix| |0.0.1|2015-11-27|Initial commit|
Initially Generated with generator-mpnodemodule
Other projects
|Name|Description| |:--|:--| |node-cache|Simple and fast NodeJS internal caching. Node internal in memory cache like memcached.| |rsmq|A really simple message queue based on redis| |redis-heartbeat|Pulse a heartbeat to redis. This can be used to detach or attach servers to nginx or similar problems.| |systemhealth|Node module to run simple custom checks for your machine or it's connections. It will use redis-heartbeat to send the current state to redis.| |rsmq-cli|a terminal client for rsmq| |rest-rsmq|REST interface for.| |nsq-logger|Nsq service to read messages from all topics listed within a list of nsqlookupd services.| |nsq-topics|Nsq helper to poll a nsqlookupd service for all it's topics and mirror it locally.| |nsq-nodes|Nsq helper to poll a nsqlookupd service for all it's nodes and mirror it locally.| |nsq-watch|Watch one or many topics for unprocessed messages.| |redis-sessions|An advanced session store for NodeJS and Redis| |connect-redis-sessions|A connect or express middleware to simply use the redis sessions. With redis sessions you can handle multiple sessions per user_id.| |redis-notifications|A redis based notification engine. It implements the rsmq-worker to safely create notifications and recurring reports.| |hyperrequest|A wrapper around hyperquest to handle the results| |task-queue-worker|A powerful tool for background processing of tasks that are run by making standard http requests |soyer|Soyer is small lib for server side use of Google Closure Templates with node.js.| |grunt-soy-compile|Compile Goggle Closure Templates ( SOY ) templates including the handling of XLIFF language files.| |backlunr|A solution to bring Backbone Collections together with the browser fulltext search engine Lunr.js| |domel|A simple dom helper if you want to get rid of jQuery| |obj-schema|Simple module to validate an object by a predefined schema|
The MIT License (MIT)
Copyright © 2015 M. Peter, http://www.tcs.de
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.