wl-stations-http
用于 vue3 - vite
Http 使用方法
注意,目前仅支持 post 和 get 方法
下载
//在控制台输入命令安装
npm i wl-stations-http
使用
// 构建http对象
let http = new Http({
baseUrl: "", //请求基础路径
serviceName: " ", //自服务的名称
rpcUrl: " ", // psc节点的地址,不填则默认为 https://psc-mainnet.polysmartchain.com
content: " ",
signature: " ",
});
调用接口
http
.post(`proposal/pip/proposal`, {
pageNum: 1,
pageSize: 10,
})
.then((res) => {
console.log("响应结果", res);
});
// or
let { data: res } = await http.post(`proposal/pip/proposal`, {
pageNum: 1,
pageSize: 10,
});
添加请求或响应拦截器 (可以添加多个)
// 添加请求拦截器
http.addRequestInterceptor((config) => {
/*
let config = {
method: "POST",
headers: { "Content-Type": "application/json", ...headers },
body: JSON.stringify(params),
url: await this.initUrl(path),
};
*/
if (config.url.includes("/api/points")) {
config.baseURL = "https://burnrate.polysmartchain.com";
}
if (token) {
config.headers = {
authorization: token,
};
}
return config;
});
//响应拦截器 参数同上
// http.addResponseInterceptor(config=>{});
桥接 使用方法
Version History
| Version | Released | License |
|---|---|---|
| 2.0.0 | ISC | |
| 1.1.13 | ISC | |
| 1.1.12 | ISC | |
| 1.1.11 | ISC | |
| 1.1.10 | ISC | |
| 1.1.9 | ISC | |
| 1.1.8 | ISC | |
| 1.1.7 | ISC | |
| 1.1.6 | ISC | |
| 1.1.3 | ISC | |
| 1.1.2 | ISC | |
| 1.1.1 | ISC | |
| 1.1.0 | ISC | |
| 1.0.39 | ISC | |
| 1.0.38 | ISC | |
| 1.0.37 | ISC | |
| 1.0.36 | ISC | |
| 1.0.35 | ISC | |
| 1.0.34 | ISC | |
| 1.0.33 | ISC | |
| 1.0.32 | ISC | |
| 1.0.30 | ISC | |
| 1.0.29 | ISC | |
| 1.0.28 | ISC | |
| 1.0.27 | ISC | |
| 1.0.26 | ISC | |
| 1.0.25 | ISC | |
| 1.0.24 | ISC | |
| 1.0.23 | ISC | |
| 1.0.22 | ISC |
Showing the latest 30 of 49. See every release on npm