
Company News
Socket Joins the OpenJS Foundation
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.
promise-buffer-request
Advanced tools
Node.js HTTP请求库Buffer-Request的Promise版本。点击了解Buffer-Request。
同类HTTP请求库推荐。
由于只需要适配较少的情况,因此代码量非常少,就一个基础文件,你可以直接复制到自己的项目中。非常适合Serverless场景,减少容器冷启动时间。
$ npm install promise-buffer-request
支持2种调用方式,首先先引用:
const request = require('promise-text-request')
第1种调用方式,直接输入请求地址:
request(url).then(resolve,reject)
例如:
request('http://www.example.com').then(function (response) {
console.log(response)
}, function (err) {
console.log(err)
})
这种方式默认请求方法GET,无Body。如果需要更复杂的请求形式,请使用以下第2种调用方式:
request(options).then(resolve,reject)
例如:
let options = {
url:'http://www.example.com', // 请求地址
method:'POST', // 请求方法
headers:{}, // 请求头
body:'{"name":"ming"}', // 请求体
base64Encoded:true // 是否需要将响应主体使用base64转码
}
request(options).then(function (response) {
console.log(response)
}, function (err) {
console.log(err)
})
FAQs
Promise version for Buffer-Request
The npm package promise-buffer-request receives a total of 1 weekly downloads. As such, promise-buffer-request popularity was classified as not popular.
We found that promise-buffer-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.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.