Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
hrsoft-ds 是基于是基于fetch api 的一套前后端通用请求库,支持 get, post, delete, put
四种请求方式,默认请求头 Content-type
为 application/x-www-form-urlencoded
npm install hrsoft-ds --save
bower install hrsoft-ds --save
import ds from 'hrsoft-ds';
//or
const ds = require('hrsoft-ds');
//register
ds.register('user.info', {
type: 'get',
url: '/user/info',
headers:{}
});
//resolve
ds.resolve('user.info', {
headers:{
'Accept':'application/json'
},
qs:{
id:1
}
}).then(function(result) {
console.log(result);
});
//or
ds.resolve('user.info', {
id:1
}).then(function(result) {
console.log(result);
});
user/:id
,则会先去查找options里面的 id 去替换 url 里面的 id,剩余参数默认带到url queryString里面去,如果是post || update 方法,
首先也会替换url 里面的 path 参数,但是剩余参数会默认带到请求 body 里面;//register
ds.register('user.login', {
type: 'post',
url: '/user/login',
headers:{
'Content-type': 'application/json'
}
});
//resolve
ds.resolve('user.login', {
headers:{
'Accept':'application/json'
},
body:{
name:'kuaizhan',
password:'123456'
}
}).then(function(result) {
console.log(result);
});
//or
ds.resolve('user.login', {
name:'kuaizhan',
password:'123456'
}).then(function(result) {
console.log(result);
});
hrsoft-ds 内部重载了 Error 对象重载,可以通过捕获错误的错误码处理相应的错误
code | message |
---|---|
0 | 网络请求发生错误 |
1 | 参数不正确 |
2 | 请求方式不允许 |
3 | 服务端返回数据格式不正确 |
4 | 未知错误 |
5 | 需要发布获取网络请求配置 |
FAQs
hrsoft 前后端通用网络请求库
The npm package hrsoft-ds receives a total of 2 weekly downloads. As such, hrsoft-ds popularity was classified as not popular.
We found that hrsoft-ds 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.