
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Cuddle is a minimal, chainable, retryable and "readability first" node http client. It's built to use for calling third-party APIs. Just what you need.
npm i cuddle@latest -S
.then
or .end
is calledconst cudl = require('cuddle');
cudl.post
.to('http://localhost:8082/api/user/1')
.set_header('Authorization', 'Token sampletoken')
.send({
username: 'rvnjl',
sex: 'male'
})
.then((err, result) => {
if (err) {
//handle error
}
console.log(result);
});
const cudl = require('cuddle');
cudl.post
.to('http://localhost:8082/api/user/1')
.set_header('Authorization', 'Token sampletoken')
.send({
username: 'rvnjl',
sex: 'male'
})
.promise()
.then(success)
.catch(fail);
const cudl = require('cuddle');
const co = require('co');
function* foo () {
let user = yield cudl.get
.to('http://localhost:8082/api/user/1')
.set_header('Authorization', 'Token sampletoken')
.promise();
console.log(user);
}
co(foo);
// will only let 50 concurrent requests
cudl.throttle(50);
const cudl = require('cuddle');
function foo () {
const users = [
{id: 1, name: 'jeff'},
{id: 2, name: 'jenny'},
{id: 3, name: 'julius'}
];
users.forEach(user => {
cudl.get
.to('http://localhost:8082/api/user/' + user.id)
.args(user)
//.max_retry(10) // default is 3
//.debug() // if you want to log all
//.logger(winston) // if you want to replace the logger (console)
.then(bar);
});
}
function bar (err, result, request, [user]) {
if (err) {
// cuddle will return a different error after reaching maximum retries
if (err.code >= 500) {
return request.retry();
}
console.error('Error with user ' + user.id + request);
return;
}
user.more_info = result;
// ...
}
foo();
FAQs
Cuddle is a minimal, chainable and readability first http client
We found that cuddle 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.