
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
一个简单的 Ajax 客服端
用法:
npm install ereq --save
import Ereq from 'ereq'
var globOpts = { baseUrl: 'http://xxx.xx.com' }
var handlers = {
successHandler: function (resText, resolve, reject) {
var res = null
try {
res = JSON.parse(resText)
} catch (e) {
reject(buildErrInfo('PARSE ERROR'))
return
}
if (res.cood === 200) {
resolve(res.data)
} else {
reject(buildErrInfo(res.msg))
}
}
}
var req = Ereq(globOpts, handlers)
var options = {
method: 'post',
url: 'api/xxxx/xxx',
params: { name: 'xxx', arg: 'xxxx' }
}
req(options)
.then(res => { console.log('ok', res)})
.catch(err => {console.log('err', err)})
默认的一些请求处理函数
var DEFAULT_HANDLERS = {
successHandler: function (resText, resolve, reject) {
var res = null
try {
res = JSON.parse(resText)
} catch (e) {
reject(buildErrInfo('PARSE ERROR'))
return
}
resolve(res)
},
errorHandler: function (xhr, reject) {
reject(buildErrInfo('REQUEST ERROR', xhr))
},
timeoutHandler: function (xhr, reject) {
reject(buildErrInfo('TIMEOUT', xhr))
}
}
可以在 Ereq(opionts, handlers) 通过 handlers 进行覆盖
默认的配置项
var DEFAULT_OPTIONS = {
baseUrl: '',
timeout: 0,
method: 'get'
}
额,代码没几行,看源码来得明白~
FAQs
一个简单的 Ajax 客服端
The npm package ereq receives a total of 1 weekly downloads. As such, ereq popularity was classified as not popular.
We found that ereq 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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.