http-promises
Consistent HTTP request API on both server and browser using promises.
API
http.get(url)
http.post(url, { payload })
http.put(url, { payload })
http.delete(url)
http.header(key, value)
Usage
Server
; let URL = "http://domain.com/foo";http ; http ;
Headers
Add headers by calling the chainable header(key, value)
method:
http
Adding headers is immutable. Each call to header
returns a fresh API. The root http
API is not effected.
Browser (Client)
Using it within the browser is exactly the same as the server, just require "http-promises/browser"
; http ;
Test
npm test