Pass onUploadProgress function through to the axios request (#6007)

The AxiosRequest config allows for an onUploadProgress function to be passed in. This is useful, if we want to
give users some kind of feedback about the progress of a potential file transfer. Currently, the sdk is only supporting
this via direct access to the transport method.

Co-authored-by: Mirko Nitschke <mnitscke93@gmail.com>
This commit is contained in:
Mirko
2021-06-03 18:44:06 +02:00
committed by GitHub
parent 979bf87921
commit 09a9f5659e
2 changed files with 3 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ export class AxiosTransport implements ITransport {
options.sendAuthorizationHeaders = options.sendAuthorizationHeaders ?? true;
options.refreshTokenIfNeeded = options.refreshTokenIfNeeded ?? true;
options.headers = options.headers ?? {};
options.onUploadProgress = options.onUploadProgress ?? undefined;
if (options.refreshTokenIfNeeded) {
await this._refresh();
@@ -59,6 +60,7 @@ export class AxiosTransport implements ITransport {
data: data,
params: options.params,
headers: options.headers,
onUploadProgress: options.onUploadProgress,
};
const token = this._storage.auth_token;

View File

@@ -24,6 +24,7 @@ export type TransportOptions = {
headers?: any;
refreshTokenIfNeeded?: boolean;
sendAuthorizationHeaders?: boolean;
onUploadProgress?: ((progressEvent: any) => void) | undefined;
};
export interface ITransport {