
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
jsonresponse2
Advanced tools
A JSON response helper forked from jsonresponse.
A standard success response would have the format:
{
"success": true,
"error": null,
"results": {
id: 123,
firstname: "Brian",
lastname: "Mancini",
age: 32
}
}
An error response would have the format:
{
"success": false,
"error": {
"message": "Code did something bad",
"stack": "Error: Code did something bad\n at Object.exports.throwError [as handle] ... "
},
"results": null
}
##Usage
Install jsonresponse2 from NPM:
npm install jsonresponse2
You can then include it in a module via:
var jsonresponse2 = require('jsonresponse2')
jsonresponse2 function takes three arguments, error, result and stringify.
To create a success response, pass in the results object, array, or value as the second argument:
var results = { foo: 'bar' }
var json = jsonresponse2(null, results)
To create an error response, pass in the error result as the first argument.
var error = new Error('Boom!')
var json = jsonresponse2(error)
You can optionally pass a third argument, a boolean, indicating whether JSON.stringify should be done on the response.
var json = jsonresponse2(null, { foo: 'bar' }, true)
FAQs
Uniform JSON response object
The npm package jsonresponse2 receives a total of 5 weekly downloads. As such, jsonresponse2 popularity was classified as not popular.
We found that jsonresponse2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.