Skip to content

Commit 7867a3f

Browse files
committed
enable raw response
1 parent 813cafc commit 7867a3f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/api.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export const request = async (
6363
data?: FormData | object | undefined,
6464
additionalHeaders: Record<string, string> = {},
6565
retryNumber = 0,
66-
options: RequestOptions = {}
66+
options: RequestOptions = {},
67+
returnRaw = false
6768
): Promise<any> => {
6869
const body = data instanceof Array ? data && [...data] : data && { ...data };
6970

@@ -119,13 +120,19 @@ export const request = async (
119120
data,
120121
additionalHeaders,
121122
retryNumber + 1,
122-
options
123+
options,
124+
returnRaw
123125
)
124126
);
125127
});
126128
}
127129
}
128130

131+
if (returnRaw) {
132+
resolve(response);
133+
return response;
134+
}
135+
129136
const imageTypes = ["image/gif", "image/jpeg", "image/png"];
130137
const { headers } = response;
131138
const type = headers.get("Content-Type");
@@ -182,7 +189,8 @@ export const authenticatedRequest = async (
182189
data?: FormData | object | undefined,
183190
additionalHeaders: Record<string, string> = {},
184191
retryNumber = 0,
185-
options: RequestOptions = {}
192+
options: RequestOptions = {},
193+
returnRaw = false
186194
): Promise<any> => {
187195
const token = await authenticationPromise;
188196
if (!token) {
@@ -208,14 +216,16 @@ export const authenticatedRequest = async (
208216
data,
209217
additionalHeaders,
210218
retryNumber + 1,
211-
options
219+
options,
220+
returnRaw
212221
)
213222
);
214223
}
215224

216225
const authenticationHeaders = {
217226
Authorization: `Bearer ${token.access_token}`
218227
};
228+
219229
return request(
220230
url,
221231
method,
@@ -225,7 +235,8 @@ export const authenticatedRequest = async (
225235
...authenticationHeaders
226236
},
227237
retryNumber,
228-
options
238+
options,
239+
returnRaw
229240
);
230241
};
231242

src/authentication/connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const authorizationCodeCallback = async (
183183
const logInWithRedirect = async (
184184
reset = false,
185185
extraParams?: Record<string, string>
186-
) => {
186+
): Promise<any> => {
187187
console.log("In redirect...");
188188
// eslint-disable-next-line no-async-promise-executor
189189
return new Promise(async (resolve, reject) => {

0 commit comments

Comments
 (0)