diff options
Diffstat (limited to 'src/clients')
-rw-r--r-- | src/clients/api_client.ts | 15 |
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); |