diff --git a/src/front/Api/BaseApiService.ts b/src/front/Api/BaseApiService.ts index bd4a0c59..40de30f5 100644 --- a/src/front/Api/BaseApiService.ts +++ b/src/front/Api/BaseApiService.ts @@ -43,13 +43,13 @@ export default abstract class BaseApiService { return JSON.stringify(body); } - protected async getRequest(url: URL, token?: string, contentType?: ContentType, ref?: IRef) { + protected async getRequest(url: URL, token?: string, contentType?: ContentType, ref?: IRef, fileName?: string) { const request = async () => await fetch(url, { method: "GET", headers: this.buildHeaders(contentType ?? ContentType.JSON), }); - return this.sendRequest(request, ref); + return this.sendRequest(request, ref, fileName); } protected async postRequest(url: URL, body: { [key: string]: unknown } = {}, token?: string) { @@ -118,13 +118,13 @@ export default abstract class BaseApiService { return this.sendRequest(request); } - private async sendRequest(request: () => Promise, ref?: IRef): Promise { + private async sendRequest(request: () => Promise, ref?: IRef, fileName?: string): Promise { const response = await request(); - return this.processResponse(response, request, ref); + return this.processResponse(response, request, ref, fileName); } - protected async processResponse(response: Response, request: () => Promise, ref?: IRef): Promise { + protected async processResponse(response: Response, request: () => Promise, ref?: IRef, fileName?: string): Promise { let responseContent: T; ref && (ref["response"] = response); if (response.ok) { diff --git a/src/front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors.ts b/src/front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors.ts index 52735f61..11cbd40b 100644 --- a/src/front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors.ts +++ b/src/front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors.ts @@ -60,7 +60,7 @@ export default class OfficeFolderAnchors extends BaseNotary { public async download(uid: string): Promise { const url = new URL(this.baseUrl.concat(`/download/${uid}`)); try { - return await this.getRequest(url, undefined, ContentType.PDF, `${uid}.pdf`); + return await this.getRequest(url, undefined, ContentType.PDF, undefined, `${uid}.pdf`); } catch (err) { this.onError(err); return Promise.reject(err);