From f86cd3d1b248436f911dc2e1c9e71910a5302108 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 4 May 2023 21:38:28 -0600 Subject: AƱade renderizado de errores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clients/api_client.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/clients') diff --git a/src/clients/api_client.ts b/src/clients/api_client.ts index 9a0d3f5..c55a365 100644 --- a/src/clients/api_client.ts +++ b/src/clients/api_client.ts @@ -5,7 +5,14 @@ export class ApiClient { async get(path: string, params?: URLSearchParams) { const request_url = `${ this.url }${ path }`; - const response = await this.makeRequest(request_url); + const response = await this.makeGetRequest(request_url); + + return response; + } + + async post(path: string, data: FormData) { + const request_url = `${ this.url }${ path }`; + const response = await axios.post(request_url, data, { headers: { "Content-Type": "multipart/form-data"} }); return response; } @@ -13,14 +20,14 @@ export class ApiClient { async getProduct(id: string) { const request_url = `${ this.url }/products/${ id }`; const [product_response, product_reviews] = await Promise.all([ - this.makeRequest(request_url), - this.makeRequest(`${ request_url }/reviews`) + this.makeGetRequest(request_url), + this.makeGetRequest(`${ request_url }/reviews`) ]); return [product_response, product_reviews]; } - private async makeRequest(request_url: string) { + private async makeGetRequest(request_url: string) { try { const response = await axios.get(request_url); -- cgit v1.2.3