Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
request-json
Advanced tools
Request is a great HTTP client for NodeJS, but if you deal only with JSON, things could be more straightforward. This lib aims to simplify Request usage for JSON only requests.
Add it to your package.json file or run in your project folder:
npm install request-json
with Javascript:
request = require('request-json');
var client = request.newClient('http://localhost:8888/');
var data = {
title: 'my title',
content: 'my content'
};
client.post('posts/', data, function(err, res, body) {
return console.log(res.statusCode);
});
client.get('posts/', function(err, res, body) {
return console.log(body.rows[0].title);
});
data = {
title: 'my new title'
};
client.put('posts/123/', data, function(err, res, body) {
return console.log(response.statusCode);
});
client.del('posts/123/', function(err, res, body) {
return console.log(response.statusCode);
});
with Coffeescript:
Client = require('request-json')
client = request.newClient 'http://localhost:8888/'
data = title: 'my title', content: 'my content'
client.post 'posts/', data, (err, res, body) ->
console.log response.statusCode
client.get 'posts/', (err, res, body) ->
console.log body.rows[0].title
data = title: 'my new title'
client.put 'posts/123/', data, (err, res, body) ->
console.log response.statusCode
client.del 'posts/123/', (err, res, body) ->
console.log response.statusCode
with Javascript:
data = {
name: "test"
};
client.sendFile('attachments/', './test.png', data, function(err, res, body) {
if (err) {
return console.log(err);
}
});
client.saveFile('attachments/test.png', './test-get.png', function(err, res, body) {
if (err) {
return console.log(err);
}
});
with Coffeescript:
data = name: "test"
client.sendFile 'attachments/', './test.png', data, (err, res, body) ->
console.log err if err
client.saveFile 'attachments/test.png', './test-get.png', (err, res, body) ->
console.log err if err
sendFile supports too stream, array of files and array of streams to. Each file is stored with the key 'file + index' (file0, file1, file2...) in the request.
with Javascript:
client.setBasicAuth('john', 'secret');
client.get('private/posts/', function(err, res, body) {
return console.log(body.rows[0].title);
});
with Coffeescript:
client.setBasicAuth 'john', 'secret'
client.get 'private/posts/', (err, res, body) ->
console.log body.rows[0].title
FAQs
HTTP request client for JSON APIs
The npm package request-json receives a total of 0 weekly downloads. As such, request-json popularity was classified as not popular.
We found that request-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.