http-promise-api
A simple nodejs application for http requests with Promise wrapper
npm install http-promise-api
How to use
var HttpRequestAPI = HttpRequestAPI = 'your base url' header object; //get requestHttpRequestAPI
All the required headers like Content-Type, Tokens etc.. need to be inserted while constructing HttpRequestAPI.
Response/Error Formats
successful response
headers: //All headers from servers status: code:200 message:'OK' data: //desired data
Error Response
headers: status: {} error: //Any error responses from server
Methods
get(resource, query)
//url will be http://example.com/?id=123HttpRequestAPI
post(resource, postbody, query)
//url will be http://example.com/HttpRequestAPI
delete(resource, query, body)
//url will be http://example.com/?id='123'HttpRequestAPI
put(resource, postbody, query)
//url will be http://example.com/HttpRequestAPI
Generic Method
A part from above requests there is a generic request makeRequest(resource, method, query, body)
HttpRequestAPI