Skip to content

Commit

Permalink
fix aem-fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
yesil committed Mar 6, 2025
1 parent 591e713 commit ecc0f1b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 63 deletions.
32 changes: 16 additions & 16 deletions libs/deps/mas/mas.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions libs/deps/mas/merch-card.js

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions libs/features/mas/dist/mas.js

Large diffs are not rendered by default.

39 changes: 23 additions & 16 deletions libs/features/mas/src/aem-fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,34 @@ export async function getFragmentById(baseUrl, id, author, headers) {
? `${baseUrl}/adobe/sites/cf/fragments/${id}`
: `${baseUrl}/adobe/sites/fragments/${id}`;
const startTime = Date.now();
const response = await masFetch(endpoint, {
cache: 'default',
credentials: 'omit',
headers,
}).catch((e) => {
let response;
try {
response = await masFetch(endpoint, {
cache: 'default',
credentials: 'omit',
headers,
});
if (!response?.ok) {
const duration = Date.now() - startTime;
throw new MasError('Unexpected fragment response', {
response,
startTime,
duration,
});
}
return response.json();
} catch (e) {
const duration = Date.now() - startTime;
if (!response) {
response = { url: endpoint };
}

throw new MasError('Failed to get fragment', {
response,
startTime,
duration,
});
});
const duration = Date.now() - startTime;
if (!response?.ok) {
throw new MasError('Unexpected fragment response', {
response,
startTime,
duration,
});
}
return response.json();
}

let headers;
Expand Down Expand Up @@ -174,8 +181,8 @@ export class AemFragment extends HTMLElement {
})
.catch((e) => {
if (this.#rawData) {
this.cache.add(this.#rawData);
return true;
cache.add(this.#rawData);
return true;
}
this.#readyPromise = null;
this.#fail(e);
Expand Down

0 comments on commit ecc0f1b

Please sign in to comment.