call api
This commit is contained in:
parent
5f222498cb
commit
a5daa9d742
4 changed files with 114 additions and 1 deletions
24
src/interfaces/call-api.ts
Normal file
24
src/interfaces/call-api.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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.ORG_API+path;
|
||||
try {
|
||||
const response = await axios.get(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default CallAPI;
|
||||
Loading…
Add table
Add a link
Reference in a new issue