
Security News
New Study Identifies 53 Slopsquatting Targets Across 5 Frontier LLMs
Five frontier LLMs generated the same nonexistent package names, leaving 53 available for potential slopsquatting across PyPI and npm.
@deppon/deppon-request
Advanced tools
@deppon/deppon-request前端 http 请求封装包
npm install @deppon/deppon-request
import request from '@deppon/deppon-request';
// 发送 GET 请求
request({
url: '/api/data',
method: 'get',
params: {
id: 1,
},
})
.then(res => {
console.log(res);
})
.catch(err => {
console.error(err);
});
// 发送 POST 请求
request({
url: '/api/data',
method: 'post',
data: {
name: 'test',
},
})
.then(res => {
console.log(res);
})
.catch(err => {
console.error(err);
});
在 Vue 应用中安装插件:
import { createApp } from 'vue';
import { VuePlugin } from '@deppon/deppon-request';
const app = createApp(App);
// 安装插件
app.use(VuePlugin);
app.mount('#app');
<script setup>
import { useRequest } from '@deppon/deppon-request';
import { ref } from 'vue';
const request = useRequest();
const data = ref(null);
const loading = ref(false);
const fetchData = async () => {
loading.value = true;
try {
const res = await request({
url: '/api/data',
method: 'get',
params: {
id: 1,
},
});
data.value = res;
} catch (error) {
console.error(error);
} finally {
loading.value = false;
}
};
const submitData = async () => {
try {
const res = await request({
url: '/api/submit',
method: 'post',
data: {
name: 'test',
},
});
console.log(res);
} catch (error) {
console.error(error);
}
};
</script>
<template>
<div>
<button @click="fetchData" :disabled="loading">
{{ loading ? '加载中...' : '获取数据' }}
</button>
<button @click="submitData">提交数据</button>
</div>
</template>
<script>
export default {
data() {
return {
loading: false,
data: null,
};
},
methods: {
async fetchData() {
this.loading = true;
try {
// 通过 this.$request 访问
const res = await this.$request({
url: '/api/data',
method: 'get',
params: {
id: 1,
},
});
this.data = res;
} catch (error) {
console.error(error);
} finally {
this.loading = false;
}
},
async submitData() {
try {
const res = await this.$request({
url: '/api/submit',
method: 'post',
data: {
name: 'test',
},
});
console.log(res);
} catch (error) {
console.error(error);
}
},
},
};
</script>
useRequest() - 获取 request 实例request(options) - 发送 HTTP 请求url - 请求的地址(必填)method - 请求方法,默认为 'get'data - POST 请求的数据params - GET 请求的查询参数headers - 自定义请求头once - 控制接口只执行一次(可选)// GET 请求
request({
url: '/api/users',
method: 'get',
params: {
page: 1,
size: 10,
},
});
// POST 请求
request({
url: '/api/users',
method: 'post',
data: {
name: 'John',
age: 30,
},
});
// 只执行一次的请求
request({
url: '/api/submit',
method: 'post',
data: { name: 'test' },
once: true,
});
更多 API 请参考源码。
本包自动处理 Cookie 跨域设置,确保在跨域请求时能够正确携带 Cookie。
withCredentials:默认设置为 true,允许跨域请求携带 Cookie
document.domain:自动调用 @deppon/deppon-utils 的 setCookieDomain() 方法设置:
deppontest.com,自动设置 document.domain = 'deppontest.com'deppon.com,自动设置 document.domain = 'deppon.com'注意:setCookieDomain 方法已从 @deppon/deppon-utils 导入,你也可以手动调用:
import { setCookieDomain } from '@deppon/deppon-utils';
setCookieDomain();
document.domain 只能在当前域或其父域上设置
a.deppon.com,可以设置为 deppon.com,但不能设置为其他域document.domain 后,端口号会被忽略withCredentials 需要服务端配合设置 Access-Control-Allow-Credentials: true 响应头import request from '@deppon/deppon-request';
// 跨域请求会自动携带 Cookie
request({
url: 'https://api.deppon.com/user/info',
method: 'get',
// withCredentials: true 已自动设置
});
FAQs
Frontend HTTP request package
The npm package @deppon/deppon-request receives a total of 4,538 weekly downloads. As such, @deppon/deppon-request popularity was classified as popular.
We found that @deppon/deppon-request demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Five frontier LLMs generated the same nonexistent package names, leaving 53 available for potential slopsquatting across PyPI and npm.

Security News
The White House’s Gold Eagle Initiative aims to coordinate AI-discovered vulnerabilities, validate findings, and accelerate patching across critical software.

Security News
A Shai-Hulud infection exposed Suno's source code, which shows the AI music startup stream-ripped tracks to train its models.