
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@fengdong/paxios
Advanced tools
axios库的上层封装
在 html 中引入,首先下载代码,然后通过script标签引入
<script src="your local directory/paxios.min.js"></script>
通过 npm 安装
npm install --save @lf/paxios --registry=http://192.168.10.152:4873
基本用法与axios一致,并且参数也一致
import paxios from 'paxios'
paxios({
url: 'http://example.com/get',
method: 'get'
})
.then((res) => {})
.catch((error) => {})
config
配置项参考:https://github.com/axios/axios
返回axios
原始对象
返回封装后的 axios 实例,可以通过该实例修改默认配置项等其他 axios 支持的操作
// 修改默认配置项
paxios.service.defaults.baseURL = 'https://api.example.com';
paxios.service.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
const request = paxios({
url: 'http://example.com/get',
method: 'get'
})
request.cancel()
fn: (config) => void
paxios.interceptor.request((config) => {
console.log(config.method)
})
对响应数据做出处理,可以添加多个
paxios.interceptor.response.use((response, next) => {
response.test = '测试拦截'
next()
// next(true)
// 如果next参数为true,则后面的拦截都不会执行
})
paxios.interceptor.response.use((response, next) => {
console.log(response.test) // 请求执行成功后会打印上面值
next()
})
http 错误码及 response拦截器中抛出的异常都会在这里被拦截
paxios.interceptor.error((error) => {
// 可以打印出 http 会返回的状态码
console.log(error.response.status)
// 可以抛出reject,以便自定义请求可以自定义错误处理,也可以不返回
return Promise.reject(error)
})
所有用 paxios
发起的请求都会添加到请求池中,请求结束会从池中删除。
该属性用于统一关闭当前未结束的请求。
paxios.requestPool.clear()
FAQs
Axios upper package
The npm package @fengdong/paxios receives a total of 0 weekly downloads. As such, @fengdong/paxios popularity was classified as not popular.
We found that @fengdong/paxios 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.