Edited OfficeFolderAnchors to re-add filename
This commit is contained in:
parent
7cbfb1cff5
commit
6de6ed0bd5
@ -43,13 +43,13 @@ export default abstract class BaseApiService {
|
||||
return JSON.stringify(body);
|
||||
}
|
||||
|
||||
protected async getRequest<T>(url: URL, token?: string, contentType?: ContentType, ref?: IRef) {
|
||||
protected async getRequest<T>(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<T>(request, ref);
|
||||
return this.sendRequest<T>(request, ref, fileName);
|
||||
}
|
||||
|
||||
protected async postRequest<T>(url: URL, body: { [key: string]: unknown } = {}, token?: string) {
|
||||
@ -118,13 +118,13 @@ export default abstract class BaseApiService {
|
||||
return this.sendRequest<T>(request);
|
||||
}
|
||||
|
||||
private async sendRequest<T>(request: () => Promise<Response>, ref?: IRef): Promise<T> {
|
||||
private async sendRequest<T>(request: () => Promise<Response>, ref?: IRef, fileName?: string): Promise<T> {
|
||||
const response = await request();
|
||||
|
||||
return this.processResponse<T>(response, request, ref);
|
||||
return this.processResponse<T>(response, request, ref, fileName);
|
||||
}
|
||||
|
||||
protected async processResponse<T>(response: Response, request: () => Promise<Response>, ref?: IRef): Promise<T> {
|
||||
protected async processResponse<T>(response: Response, request: () => Promise<Response>, ref?: IRef, fileName?: string): Promise<T> {
|
||||
let responseContent: T;
|
||||
ref && (ref["response"] = response);
|
||||
if (response.ok) {
|
||||
|
@ -60,7 +60,7 @@ export default class OfficeFolderAnchors extends BaseNotary {
|
||||
public async download(uid: string): Promise<any> {
|
||||
const url = new URL(this.baseUrl.concat(`/download/${uid}`));
|
||||
try {
|
||||
return await this.getRequest<any>(url, undefined, ContentType.PDF, `${uid}.pdf`);
|
||||
return await this.getRequest<any>(url, undefined, ContentType.PDF, undefined, `${uid}.pdf`);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
|
Loading…
x
Reference in New Issue
Block a user