Skip to content

Commit

Permalink
fix(headers): additionalRequestHeaders is now sent in the requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dependentmadani committed Jul 10, 2024
1 parent 10336e0 commit da9b403
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/types/codexteam__ajax.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ declare module '@codexteam/ajax' {
url?: string;
data?: any;
accept?: string;
headers?: Headers;
headers?: Record<string, string> | Headers;
beforeSend?: (files: File[]) => void;
fieldName?: string;
type?: string;
Expand Down
8 changes: 4 additions & 4 deletions src/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export default class Uploader<AdditionalUploadResponse = {}> {
url: this.config.endpoints.byFile,
data: this.config.additionalRequestData,
accept: this.config.types,
headers: new Headers(this.config.additionalRequestHeaders as Record<string, string>),
headers: this.config.additionalRequestHeaders as Record<string, string>,
beforeSend: (files: File[]) => {
preparePreview(files[0]);
},
fieldName: this.config.field,
}).then((response: any) => response.body);
}

upload.then((response) => {
upload.then((response) => {
this.onUpload(response as UploadResponseFormat<AdditionalUploadResponse>);
}).catch((error) => {
this.onError(error);
Expand Down Expand Up @@ -133,7 +133,7 @@ export default class Uploader<AdditionalUploadResponse = {}> {
url: url,
}, this.config.additionalRequestData),
type: ajax.contentType.JSON,
headers: new Headers(this.config.additionalRequestHeaders as Record<string, string>),
headers: this.config.additionalRequestHeaders as Record<string, string>,
}).then((response: any) => response.body);
}

Expand Down Expand Up @@ -193,7 +193,7 @@ export default class Uploader<AdditionalUploadResponse = {}> {
url: this.config.endpoints.byFile,
data: formData,
type: ajax.contentType.JSON,
headers: new Headers(this.config.additionalRequestHeaders as Record<string, string>),
headers: this.config.additionalRequestHeaders as Record<string, string>,
}).then((response: any) => response.body);
}

Expand Down

0 comments on commit da9b403

Please sign in to comment.