summaryrefslogtreecommitdiff
path: root/src/clients/api_client.ts
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-05-04 21:38:28 -0600
committerHombreLaser <sebastian-440@live.com>2023-05-04 21:38:28 -0600
commitf86cd3d1b248436f911dc2e1c9e71910a5302108 (patch)
tree09a216ea01ff2d310485cf1d281c9daa6b75b232 /src/clients/api_client.ts
parent3d29fc04eec0e32df4d9c66388fb2303d01dac45 (diff)
Añade renderizado de errores
Diffstat (limited to 'src/clients/api_client.ts')
-rw-r--r--src/clients/api_client.ts15
1 files changed, 11 insertions, 4 deletions
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);