fix: get API의 경우 arg를 paramArg로 전환

This commit is contained in:
2022-04-21 00:24:21 +09:00
parent 7043521eaa
commit 095a23df6d
+25 -10
View File
@@ -65,17 +65,32 @@ export async function callSammoAPI<ResultType extends ValidResponse, ErrorType e
args = undefined;
}
const result = await ky('api.php', {
searchParams: {
...paramArgs,
path,
},
method,
json: args,
headers: {
'content-type': 'application/json'
const result = await (() => {
if (method == 'get') {
return ky('api.php', {
searchParams: {
...paramArgs,
...(args as typeof paramArgs),
path,
},
method,
headers: {
'content-type': 'application/json'
}
});
}
}).json() as ErrorType | ResultType;
return ky('api.php', {
searchParams: {
...paramArgs,
path,
},
method,
json: args,
headers: {
'content-type': 'application/json'
}
});
})().json() as ErrorType | ResultType;
if (!result.result) {
if (returnError) {