svb-client
Advanced tools
Comparing version 2.3.2 to 2.4.2
@@ -57,7 +57,15 @@ // | ||
get: function(path, query, callback) { | ||
let headers = this._getHeaders("GET", path, query, ""); | ||
delete: function(path, callback) { | ||
this.get(path, '', callback, 'DELETE'); | ||
}, | ||
get: function(path, query, callback, overrideMethod) { | ||
if (!overrideMethod) { | ||
overrideMethod = 'GET'; | ||
} | ||
let headers = this._getHeaders(overrideMethod, path, query, ""); | ||
request({ | ||
uri: this.baseurl + path + '?' + query, | ||
url: this.baseurl + path + '?' + query, | ||
method: overrideMethod, | ||
headers: headers | ||
@@ -78,6 +86,13 @@ }, (err, response, body) => { | ||
post: function(path, postdata, callback) { | ||
patch: function(path, postdata, callback) { | ||
this.post(path, postdata, callback, 'PATCH'); | ||
}, | ||
post: function(path, postdata, callback, overrideMethod) { | ||
if (typeof postdata === 'string') { | ||
postdata = JSON.parse(postdata); | ||
} | ||
if (!overrideMethod) { | ||
overrideMethod = 'POST'; | ||
} | ||
if (!postdata.data && Object.keys(postdata).length > 0) { | ||
@@ -88,7 +103,7 @@ // send data inside of a data wrapper | ||
let stringedpost = JSON.stringify(postdata); | ||
let headers = this._getHeaders("POST", path, "", stringedpost); | ||
let headers = this._getHeaders(overrideMethod, path, "", stringedpost); | ||
request({ | ||
url: this.baseurl + path, | ||
method: 'POST', | ||
method: overrideMethod, | ||
headers: headers, | ||
@@ -95,0 +110,0 @@ json: postdata |
{ | ||
"name": "svb-client", | ||
"version": "2.3.2", | ||
"version": "2.4.2", | ||
"description": "NodeJS request client for SVB API", | ||
@@ -5,0 +5,0 @@ "main": "client.js", |
@@ -34,2 +34,6 @@ ## svb-client | ||
// similar | ||
client.patch(url, jsondata, callback); | ||
client.delete(url, callback); | ||
// uploading a file | ||
@@ -36,0 +40,0 @@ const fs = require('fs'); |
Sorry, the diff of this file is not supported yet
4797
134
44