Commit 21b2db98 authored by timel's avatar timel

feat: remove axios

parent 124c86b4
......@@ -21,7 +21,6 @@
"@types/react-dom": "^18.0.11",
"@types/sql.js": "^1.4.4",
"antd": "^5.4.0",
"axios": "^0.27.2",
"classnames": "^2.3.2",
"cookies-ts": "^1.0.5",
"eventemitter3": "^5.0.1",
......@@ -4750,15 +4749,6 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz",
"integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg=="
},
"node_modules/axios": {
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
"dependencies": {
"follow-redirects": "^1.14.9",
"form-data": "^4.0.0"
}
},
"node_modules/axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
......@@ -31984,15 +31974,6 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz",
"integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg=="
},
"axios": {
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
"requires": {
"follow-redirects": "^1.14.9",
"form-data": "^4.0.0"
}
},
"axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
import axios from "axios";
const API_URL = "https://sapi.moecube.com:444/ygopro/match";
export interface MatchInfo {
......@@ -14,19 +12,26 @@ export async function match(
arena: string = "entertain"
): Promise<MatchInfo | undefined> {
const headers = { Authorization: "Basic " + btoa(username + ":" + extraId) };
const response = await axios
.post(API_URL, undefined, {
headers: headers,
params: {
arena,
// TODO: locale?
},
})
.catch((error) => {
console.error(`match error: ${error}`);
let response: Response | undefined = undefined;
const params = new URLSearchParams({
arena,
// TODO: locale?
});
return undefined;
try {
const resp = await fetch(API_URL + "?" + params.toString(), {
method: "POST",
headers: headers,
});
return response ? response.data : undefined;
if (resp.ok) {
response = resp;
} else {
console.error(`match error: ${resp.status}`);
}
} catch (error) {
console.error(`match error: ${error}`);
}
return (await response?.json()) as MatchInfo;
}
import axios from "axios";
import { useConfig } from "@/config";
import { fetchCard, getCardStr } from "./cards";
const NeosConfig = useConfig();
const { stringsUrl } = useConfig();
export const DESCRIPTION_LIMIT = 10000;
export async function initStrings() {
const strings = (await axios.get<string>(NeosConfig.stringsUrl)).data;
const strings = await (await fetch(stringsUrl)).text();
console.log({ strings });
const lineIter = strings.split("\n");
for (const line of lineIter) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment