Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-json

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-json - npm Package Compare versions

Comparing version 0.4.4 to 0.4.5

66

main.js

@@ -29,13 +29,17 @@ // Generated by CoffeeScript 1.6.3

exports.newClient = function(url) {
return new exports.JsonClient(url);
exports.newClient = function(url, options) {
if (options == null) {
options = {};
}
return new exports.JsonClient(url, options);
};
exports.JsonClient = (function() {
function JsonClient(host) {
function JsonClient(host, options) {
var _ref;
this.host = host;
this.headers = {
accept: 'application/json',
"user-agent": "request-json/1.0"
};
this.options = options != null ? options : {};
this.headers = (_ref = this.options.headers) != null ? _ref : {};
this.headers['accept'] = 'application/json';
this.headers['user-agent'] = "request-json/1.0";
}

@@ -55,10 +59,11 @@

JsonClient.prototype.get = function(path, callback, parse) {
var options;
if (parse == null) {
parse = true;
}
return request({
method: 'GET',
uri: url.resolve(this.host, path),
headers: this.headers
}, function(error, response, body) {
options = this.options;
options.method = 'GET';
options.uri = url.resolve(this.host, path);
options.headers = this.headers;
return request(options, function(error, response, body) {
if (parse) {

@@ -73,11 +78,12 @@ return parseBody(error, response, body, callback);

JsonClient.prototype.post = function(path, json, callback, parse) {
var options;
if (parse == null) {
parse = true;
}
return request({
method: "POST",
uri: url.resolve(this.host, path),
json: json,
headers: this.headers
}, function(error, response, body) {
options = this.options;
options.method = "POST";
options.uri = url.resolve(this.host, path);
options.json = json;
options.headers = this.headers;
return request(options, function(error, response, body) {
if (parse) {

@@ -92,11 +98,12 @@ return parseBody(error, response, body, callback);

JsonClient.prototype.put = function(path, json, callback, parse) {
var options;
if (parse == null) {
parse = true;
}
return request({
method: "PUT",
uri: url.resolve(this.host, path),
json: json,
headers: this.headers
}, function(error, response, body) {
options = this.options;
options.method = "PUT";
options.uri = url.resolve(this.host, path);
options.json = json;
options.headers = this.headers;
return request(options, function(error, response, body) {
if (parse) {

@@ -111,10 +118,11 @@ return parseBody(error, response, body, callback);

JsonClient.prototype.del = function(path, callback, parse) {
var options;
if (parse == null) {
parse = true;
}
return request({
method: "DELETE",
uri: url.resolve(this.host, path),
headers: this.headers
}, function(error, response, body) {
options = this.options;
options.method = "DELETE";
options.uri = url.resolve(this.host, path);
options.headers = this.headers;
return request(options, function(error, response, body) {
if (parse) {

@@ -121,0 +129,0 @@ return parseBody(error, response, body, callback);

@@ -16,3 +16,3 @@ {

],
"version": "0.4.4",
"version": "0.4.5",
"homepage": "https://github.com/mycozycloud/request-json/",

@@ -29,2 +29,3 @@ "bugs": {

"Fábio Santos",
"Stephen Tweeddale",
"Benjamin Woodruff"

@@ -31,0 +32,0 @@ ],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc