แก้ call api

This commit is contained in:
kittapath 2024-09-30 09:45:36 +07:00
parent 0be33a3f3a
commit f8a91f60ba

View file

@ -17,7 +17,7 @@ import { addLogSequence } from "./utils";
class CallAPI { class CallAPI {
//Get //Get
public async GetData(request: any, @Path() path: any) { public async GetData(request: any, @Path() path: any) {
const token = request.headers.authorization; const token = "Bearer " + request.headers.authorization.replace("Bearer ", "");
const url = process.env.API_URL + path; const url = process.env.API_URL + path;
try { try {
const response = await axios.get(url, { const response = await axios.get(url, {
@ -54,7 +54,7 @@ class CallAPI {
} }
//Post //Post
public async PostData(request: any, @Path() path: any, sendData: any) { public async PostData(request: any, @Path() path: any, sendData: any) {
const token = request.headers.authorization; const token = "Bearer " + request.headers.authorization.replace("Bearer ", "");
const url = process.env.API_URL + path; const url = process.env.API_URL + path;
try { try {
const response = await axios.post(url, sendData, { const response = await axios.post(url, sendData, {