hrms-api-salary/src/interfaces/call-api.ts

36 lines
629 B
TypeScript
Raw Normal View History

2024-02-28 11:27:52 +07:00
import {
Controller,
Request,
Get,
Post,
Put,
Delete,
Patch,
Route,
Security,
Tags,
Path,
} from "tsoa";
import axios from "axios";
2024-02-28 10:37:48 +07:00
class CallAPI {
2024-02-28 11:27:52 +07:00
//Get
public async GetData(request: any, @Path() path: any) {
const token = request.headers.authorization;
const url = process.env.ORG_API + path;
try {
const response = await axios.get(url, {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
});
return response.data.result;
} catch (error) {
throw error;
2024-02-28 10:37:48 +07:00
}
2024-02-28 11:27:52 +07:00
}
2024-02-28 10:37:48 +07:00
}
2024-02-28 11:27:52 +07:00
export default CallAPI;