Giter Site home page Giter Site logo

littlerequester's Introduction

Littlerequester

Build Status npm version

Description

Simple NodeJS HTTP/HTTPS request module with no dependency
Support GET, POST, PUT, PATCH, DELETE request type

Test

Tested for NodeJS 4, 5 and 6

Installation

$ npm i littlerequester --save

Usage

With just a string

const littlerequester = require("littlerequester");

// Make a request to example.com
// you can also directly get json like this -> littlerequester("http://example.com/", "json")
littlerequester("http://example.com/").then(data => {
    // Get raw Data
    console.log(data.data);
    // Get node http response object
    console.log(data.res);
}, e => {
    console.log(e);
})

Or with a more complex object

const littlerequester = require("littlerequester");

// Make a request to example.com
littlerequester({url: "http://example.com/", type: "raw"}).then(data => {
    // Get raw Data
    console.log(data.data);
    // Get node http response object
    console.log(data.res);
}, e => {
    console.log(e);
})

Or

const littlerequester = require("littlerequester");

littlerequester({url: "https://example.com/", type: "json"}).then(data => {
  // Get json Data
  console.log(data.data);
  // Get node http response object
  console.log(data.res);
}, e => {
    console.log(e);
});

littlerequester argument doc

2 params

  • url - String : An url
  • type? - String : json or raw (default to raw) - Optional

OR

param - Object : options An object with the following fields :

  • url - String : Request url
  • type - String : Return data type either json or raw
  • headers - Object : Object with header to use in request (ex: user-agent)
  • method? - String : GET, POST, PUT, PATCH, DELETE default to GET if not provided - Optional
  • data? - Object : Valid Object for POST, PUT and PATCH request - Optional

Release History

  • 0.5.0 add 2nd arg (type - Optional) for request with just a string
  • 0.4.0 add request with just an url
  • 0.3.0 add POST, PUT, PATCH, DELETE request type
  • 0.2.0 Add headers support
  • 0.1.0 Initial release

littlerequester's People

Contributors

azsiaz avatar

Watchers

 avatar  avatar  avatar

littlerequester's Issues

Support new options

  • Add support for header (ex user-agent header required by github api)
  • DELETE request
  • POST request
  • PUT request
  • PATCH request

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.