@sfd-br/request-util
v0.1.11
Published
SFD utility to make Resquests
Downloads
9
Keywords
Readme
Http Utility to make the SFD Standard Response
Install
$ npm i -S @sfd-br/request-util
Usage
const responseUtil = require('@sfd-br/request-util');
// configure query params
configParams: configParams(params),
// make the request
makeRequest: makeRequest(method, url, body)
// method constants
GET: 'GET',
POST: 'POST',
PUT: 'PUT',
PATCH: 'PATCH',
DELETE: 'DELETE'
Example
const responseUtil = require('@sfd-br/request-util');
function getResidencialAddress(cep) {
var deferred = q.defer();
var url = "https://viacep.com.br/ws/" + cep + "/json/";
requestUtil.makeRequest(requestUtil.GET, url).then(
function(result){
deferred.resolve(result);
}).catch(function(error){
deferred.reject(error);
});
return deferred.promise;
}
License
SFD