Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
npm install vxe-ajax --save
import Vue from 'vue'
import XEAjax from 'vxe-ajax'
Vue.use(XEAjax)
// 返回response对象
this.get('url').then(response => {
// this 指向当前vue实例
response.body
}).catch(response => {
// this 指向当前vue实例
response.body
response.status
})
// 直接返回数据
this.getJSON('url').then(data => {
// this 指向当前vue实例
}).catch(data => {
// this 指向当前vue实例
})
// url参数和数据同时提交
this.postJSON('url', {name: 'aaa'}, {params: {id: 1}}).then(data => {
// this 指向当前vue实例
}).catch(data => {
// this 指向当前vue实例
})
参数 | 类型 | 描述 | 值 |
---|---|---|---|
url | String | 请求地址 | |
baseURL | String | 基础路径 | |
method | String | 请求方法 | 默认get |
params | Object/Array | 请求参数 | |
body | Object/Array | 提交参数 | |
bodyMode | String | 提交参数方式 | 默认json,如果要以表单方式提交改为'formData' |
jsonp | String | 调用jsonp服务,回调属性默认callback | 默认callback |
jsonpCallback | String | jsonp回调函数名 | 默认从window取值 |
async | Boolean | 是否异步 | true |
timeout | Number | 设置超时 | |
headers | Object | 请求头 | |
iterators | Function | 局部拦截器 |
Vue.ajax.defaults = {
baseURL: 'xxx.com',
bodyMode: 'formData',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
Vue.ajax.oninterceptor = (request, next) => {
// 请求之前处理
// 更改请求类型为POST
request.method = 'post'
// 继续执行,如果不调用next则不会往下走
next()
}
Vue.ajax.oninterceptor = (request, next) => {
// 请求之前处理
// 继续执行
next( (response) => {
// 请求之后处理
// 更改请求结果数据
response.body = {}
})
}
Vue.ajax.oninterceptor = (request, next) => {
// 请求之前处理
// 继续执行,如果希望直接返回数据,结束请求
// 直接返回
// next({response: [{id: 1}, {id: 2}], status: 500})
// 异步返回
new Promise( (resolve, reject) => {
setTimeout( () => {
next({response: {a: 1, b: 2}, status: 200})
}, 10)
})
}
Copyright (c) 2017-present, Xu Liangzhan
FAQs
用于 Vue 全局安装 xe-ajax
The npm package vxe-ajax receives a total of 11 weekly downloads. As such, vxe-ajax popularity was classified as not popular.
We found that vxe-ajax 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.