This commit is contained in:
AdisakKanthawilang 2024-07-25 17:06:42 +07:00
parent 4b34fc20b8
commit 1c9cb7ea78
11 changed files with 741 additions and 122 deletions

View file

@ -12,6 +12,7 @@ import {
Path,
} from "tsoa";
import axios from "axios";
import { addLogSequence } from "./utils";
class CallAPI {
//Get
@ -25,8 +26,26 @@ class CallAPI {
"Content-Type": "application/json",
},
});
addLogSequence(request, {
action: "request",
status: "success",
description: JSON.stringify(response.data.result),
request: {
method: "GET",
url: url,
},
});
return response.data.result;
} catch (error) {
addLogSequence(request, {
action: "request",
status: "error",
description: JSON.stringify(error),
request: {
method: "GET",
url: url,
},
});
throw error;
}
}
@ -41,8 +60,26 @@ class CallAPI {
"Content-Type": "application/json",
},
});
addLogSequence(request, {
action: "request",
status: "success",
description: JSON.stringify(response.data.result),
request: {
method: "POST",
url: url,
},
});
return response.data.result;
} catch (error) {
addLogSequence(request, {
action: "request",
status: "error",
description: JSON.stringify(error),
request: {
method: "POST",
url: url,
},
});
throw error;
}
}