Socket
Socket
Sign inDemoInstall

callarest

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callarest - npm Package Compare versions

Comparing version 1.6.0 to 2.0.0

14

index.js

@@ -9,10 +9,10 @@ const http = require('http');

const headers = options.headers || {};
if (options.data != null) {
if (typeof options.data !== 'string') {
if (options.body != null) {
if (typeof options.body !== 'string') {
return callback(new ErrorWithObject({
message: 'You did not set the data property to an String. Did you mean to JSON.stringify an object it or use the callarest.json shortcut?',
code: 'SENT_OBJECT_AS_DATA'
message: 'You did not set the body property to an String. Did you mean to JSON.stringify an object it or use the callarest.json shortcut?',
code: 'SENT_OBJECT_AS_BODY'
}));
}
headers['Content-Length'] = Buffer.byteLength(options.data);
headers['Content-Length'] = Buffer.byteLength(options.body);
}

@@ -53,4 +53,4 @@

if (options.data) {
request.write(options.data);
if (options.body) {
request.write(options.body);
}

@@ -57,0 +57,0 @@ request.end();

@@ -10,5 +10,5 @@ const ErrorWithObject = require('error-with-object');

let data;
if (options.data != null) {
data = JSON.stringify(options.data);
let body;
if (options.body != null) {
body = JSON.stringify(options.body);
}

@@ -19,3 +19,3 @@

headers,
data
body
}, function (error, rest) {

@@ -22,0 +22,0 @@ if (error) {

{
"name": "callarest",
"version": "1.6.0",
"version": "2.0.0",
"keywords": [

@@ -28,9 +28,9 @@ "rest",

"devDependencies": {
"tape": "^4.11.0",
"c8": "^6.0.1",
"tape": "^4.13.2",
"righto": "^6.0.1"
},
"dependencies": {
"c8": "^6.0.1",
"error-with-object": "^1.1.0"
}
}

@@ -13,6 +13,6 @@ # Callarest

```javascript
const callarestJson = require('callarest/json')
callarestJson({
const callarest = require('callarest')
callarest({
method: 'post',
data: JSON.stringify({ hello: 'world' }),
body: JSON.stringify({ hello: 'world' }),
headers: {

@@ -39,3 +39,3 @@ 'Content-Type': 'application/json'

method: 'post',
data: { hello: 'world' },
body: { hello: 'world' },
url: 'https://www.example.com'

@@ -42,0 +42,0 @@ }, function (error, rest) {

@@ -81,3 +81,3 @@ const test = require('tape');

url: 'http://localhost:8000/echo',
data: { b: 1 }
body: { b: 1 }
}, righto.after(server));

@@ -94,3 +94,3 @@

test('post -> send object as data', t => {
test('post -> send object as body', t => {
t.plan(1);

@@ -102,3 +102,3 @@

url: 'http://localhost:8000/echo',
data: 'something'
body: 'something'
}, righto.after(server));

@@ -105,0 +105,0 @@

@@ -60,3 +60,3 @@ const test = require('tape');

url: 'http://localhost:8000/echo',
data: 'hello'
body: 'hello'
}, righto.after(server));

@@ -73,3 +73,3 @@

test('post -> send object as data', t => {
test('post -> send object as body', t => {
t.plan(1);

@@ -81,3 +81,3 @@

url: 'http://localhost:8000/echo',
data: {
body: {
a: 1

@@ -88,3 +88,3 @@ }

request(function (error, result) {
t.equal(error.code, 'SENT_OBJECT_AS_DATA');
t.equal(error.code, 'SENT_OBJECT_AS_BODY');

@@ -91,0 +91,0 @@ destroyServer();

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