feat: 턴 선택기를 vue 기반으로 변경
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import axios from "axios";
|
||||
import { isArray } from "lodash";
|
||||
import { InvalidResponse } from "../defs";
|
||||
|
||||
type ValidResponse = {
|
||||
result: true
|
||||
}
|
||||
|
||||
export async function sammoAPI<ResultType extends ValidResponse>(path: string | string[], args?: Record<string, unknown>): Promise<ResultType> {
|
||||
if (isArray(path)) {
|
||||
path = path.join('/');
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
url: "api.php",
|
||||
method: "post",
|
||||
responseType: "json",
|
||||
data: {
|
||||
path,
|
||||
args,
|
||||
},
|
||||
});
|
||||
const result: InvalidResponse | ResultType = response.data;
|
||||
if (!result.result) {
|
||||
throw result.reason;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user