Skip to content

Commit

Permalink
feat(core): ♻️ pass headers to the request utility
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfoucrier committed May 5, 2023
1 parent 1b6c418 commit 60fa820
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ export class Core {
href,
this.timeout,
this.onRequestError.bind(this, trigger),
this.cache
this.cache,
this.headers
),
'click',
'pending'
Expand Down Expand Up @@ -460,7 +461,8 @@ export class Core {
href,
this.timeout,
this.onRequestError.bind(this, 'barba'),
this.cache
this.cache,
this.headers
).catch((error: RequestErrorOrResponse) => {
this.logger.error(error);
}),
Expand Down Expand Up @@ -525,7 +527,8 @@ export class Core {
href,
this.timeout,
this.onRequestError.bind(this, link),
this.cache
this.cache,
this.headers
).catch((error: RequestErrorOrResponse) => {
this.logger.error(error);
}),
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// Definitions
import { RequestError } from '../defs';
import { Cache } from '@barba/core/src/modules/Cache';
import { Headers } from '@barba/core/src/modules/Headers';

/**
* Init a page request.
Expand All @@ -25,7 +26,8 @@ function request(
url: string,
ttl: number = 2e3,
requestError: RequestError,
cache: Cache
cache: Cache,
headers: Headers
): Promise<string> {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
Expand Down

0 comments on commit 60fa820

Please sign in to comment.