kpi plan
This commit is contained in:
parent
c4a975b503
commit
a9dd103ff8
16 changed files with 1484 additions and 15 deletions
51
src/interfaces/call-api.ts
Normal file
51
src/interfaces/call-api.ts
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import {
|
||||
Controller,
|
||||
Request,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Patch,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Path,
|
||||
} from "tsoa";
|
||||
import axios from "axios";
|
||||
|
||||
class CallAPI {
|
||||
//Get
|
||||
public async GetData(request: any, @Path() path: any) {
|
||||
const token = request.headers.authorization;
|
||||
const url = process.env.API + path;
|
||||
try {
|
||||
const response = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
return response.data.result;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
//Post
|
||||
public async PostData(request: any, @Path() path: any, sendData: any) {
|
||||
const token = request.headers.authorization;
|
||||
const url = process.env.API + path;
|
||||
try {
|
||||
const response = await axios.post(url, sendData, {
|
||||
headers: {
|
||||
Authorization: `${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
return response.data.result;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default CallAPI;
|
||||
Loading…
Add table
Add a link
Reference in a new issue