mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-10 02:37:56 +08:00
still bugs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import axios from "axios";
|
||||
import { GlobalConf, TokenResp } from "../utils/type";
|
||||
import { GlobalConf, TokenResp, SubscribeResp, TargetNameResp } from "../utils/type";
|
||||
import { baseUrl } from './utils';
|
||||
|
||||
export async function getGlobalConf(): Promise<GlobalConf> {
|
||||
@@ -11,3 +11,13 @@ export async function auth(token: string): Promise<TokenResp> {
|
||||
const res = await axios.get<TokenResp>(`${baseUrl}auth`, {params: {token}});
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function getSubscribe(): Promise<SubscribeResp> {
|
||||
const res = await axios.get(`${baseUrl}subs`);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function getTargetName(platformName: string, target: string): Promise<TargetNameResp> {
|
||||
const res = await axios.get(`${baseUrl}target_name`, {params: {platformName, target}});
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@@ -18,4 +18,23 @@ axios.interceptors.request.use(function (config) {
|
||||
return config;
|
||||
}, function (error) {
|
||||
return Promise.reject(error);
|
||||
})
|
||||
});
|
||||
|
||||
axios.interceptors.response.use(function (response) {
|
||||
// const data = response.data;
|
||||
// const parseToMap = (item: any): any => {
|
||||
// if (item instanceof Array) {
|
||||
// return item.map(parseToMap);
|
||||
// } else if (item instanceof Object) {
|
||||
// let res = new Map();
|
||||
// for (const key of Object.keys(item)) {
|
||||
// res.set(key, parseToMap(item[key]));
|
||||
// }
|
||||
// return res;
|
||||
// } else {
|
||||
// return item;
|
||||
// }
|
||||
// }
|
||||
// response.data = parseToMap(data);
|
||||
return response;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user