Skip to content

stremlenye/immutable-http

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Immutable-http

npm version Build Status

Http client with pretty simple chaining API

Docs

Usage

import executor from 'third-party-executor'

var result = new Http().url('http://any_api.com/:id')
                        .executor(executor)
                        .method('GET')
                        .header('Content-Type','application/json')
                        .body({some:data})
                        .responseType('json')
                        .segment('id',123)
                        .query('filter','some_filter') // Adds query section for the url like '?filter=some_filter'
                        .exec(); // returns Promise

executor is just a function with signature

f(url: String, method: String, headers:Array[Tuple[String, String]], responseType: String, body: Any): Promise

It allows you to have your own favorite HTTP library under the hood and be able to test your code with mocked executor without any hacks. Executor implementation example

Build

npm run dist

Tests

Run

npm test