summaryrefslogtreecommitdiff
path: root/src/clients/api_client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/clients/api_client.ts')
-rw-r--r--src/clients/api_client.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/clients/api_client.ts b/src/clients/api_client.ts
index a7b5e0d..0e96c36 100644
--- a/src/clients/api_client.ts
+++ b/src/clients/api_client.ts
@@ -5,13 +5,28 @@ export class ApiClient {
async get(path: string) {
const request_url = `${ this.url }${ path }`;
+ const response = await this.makeRequest(request_url);
+ return response;
+ }
+
+ 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`)
+ ]);
+
+ return [product_response, product_reviews];
+ }
+
+ private async makeRequest(request_url: string) {
try {
const response = await axios.get(request_url);
- return response;
+ return response
} catch(error) {
- return error.response;
+ return error;
}
}
} \ No newline at end of file