Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
tiny_request
Advanced tools
Tiny module for http requests with no dependencies
npm install tiny_request
var req = require('tiny_request')
req.get('http://google.com', function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body)
}
})
To automatically parse JSON you just need to pass JSON parameter.
Example:
req.get({ url: 'http://test.com/json', json: true}, function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body) //body now is parsed JSON object
}
})
req.get({ url: 'http://test.com', query: { test: 'test' }}, function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body)
}
})
Where query is GET parameters object
Also you can pass port parameter, for example:
req.get({ url: 'http://test.com', port: 8080}, function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body)
}
})
var data = {
image: {
value: fs.createReadStream('photo.png'),
filename: 'photo.png',
contentType: 'image/png'
},
test: 'test'
}
req.post({
url: 'http://test.com',
query: { test: 'test' },
multipart: data
}, function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body)
}
})
var form = {
test: 'test'
}
req.post({ url: 'http://test.com', form: form}, function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body)
}
})
var data = {
test: 'test'
}
req.post({ url: 'http://test.com', jsonData: data}, function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body)
}
})
var headers = {
'Test-Header': 'test'
}
req.post({ url: 'http://test.com', headers: headers}, function(body, response, err){
if (!err && response.statusCode == 200) {
console.log(body)
}
})
req.get({url: url, pipe: stream})
req.get({url: url, timeout: 1000})
Request will be aborted after 1 second if there is no response from server
FAQs
Tiny module for networking
The npm package tiny_request receives a total of 193 weekly downloads. As such, tiny_request popularity was classified as not popular.
We found that tiny_request 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.