Skip to content

Commit ee05343

Browse files
committed
fix: create new response object
1 parent e5873ae commit ee05343

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/apps/app/app.element.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,27 +218,33 @@ export class UmbAppElement extends UmbLitElement {
218218
}
219219

220220
#attachApiInterceptor() {
221-
OpenAPI.interceptors.response.use(async (response) => {
222-
const umbNotifications = response.headers.get('umb-notifications') as string | null;
221+
OpenAPI.interceptors.response.use((response) => {
222+
const umbNotifications = response.headers.get('umb-notifications');
223223
if (!umbNotifications) return response;
224224

225225
const notifications = JSON.parse(umbNotifications);
226226
if (!isUmbNotifications(notifications)) return response;
227227

228-
const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT);
229-
for (const notification of notifications) {
230-
notificationContext.peek(extractUmbNotificationColor(notification.type), {
231-
data: { headline: notification.category, message: notification.message },
232-
});
233-
}
228+
this.getContext(UMB_NOTIFICATION_CONTEXT).then((notificationContext) => {
229+
for (const notification of notifications) {
230+
notificationContext.peek(extractUmbNotificationColor(notification.type), {
231+
data: { headline: notification.category, message: notification.message },
232+
});
233+
}
234+
});
234235

235236
const newHeader = new Headers();
236237
for (const header of response.headers.entries()) {
237238
const [key, value] = header;
238239
if (key !== 'umb-notifications') newHeader.set(key, value);
239240
}
240241

241-
const newResponse = { ...response, headers: newHeader };
242+
const newResponse = new Response(response.body, {
243+
headers: newHeader,
244+
status: response.status,
245+
statusText: response.statusText,
246+
});
247+
242248
return newResponse;
243249
});
244250
}

0 commit comments

Comments
 (0)