Skip to content

Commit a8929a0

Browse files
Merge pull request #159 from tech-sushant/screenshot-array
fix: Enhance ApiClient to support responseType in requests
2 parents a7c5d39 + 828370d commit a8929a0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/lib/apiClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type RequestOptions = {
1212
params?: Record<string, string | number>;
1313
body?: any;
1414
timeout?: number;
15+
responseType?: AxiosRequestConfig["responseType"];
1516
raise_error?: boolean; // default: true
1617
};
1718

@@ -163,12 +164,14 @@ class ApiClient {
163164
headers,
164165
params,
165166
timeout,
167+
responseType,
166168
raise_error = true,
167169
}: RequestOptions): Promise<ApiResponse<T>> {
168170
const config: AxiosRequestConfig = {
169171
headers,
170172
params,
171173
timeout,
174+
responseType,
172175
httpsAgent: this.axiosAgent,
173176
};
174177
return this.requestWrapper<T>(

src/tools/automate-utils/fetch-screenshots.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ async function convertUrlsToBase64(
5959
): Promise<Array<{ url: string; base64: string }>> {
6060
const screenshots = await Promise.all(
6161
urls.map(async (url) => {
62-
const response = await apiClient.get({ url });
62+
const response = await apiClient.get({
63+
url,
64+
responseType: "arraybuffer"
65+
});
6366
// Axios returns response.data as a Buffer for binary data
6467
const base64 = Buffer.from(response.data).toString("base64");
6568

0 commit comments

Comments
 (0)