Skip to content

Commit 8ed1c42

Browse files
author
Jonathan M. Tran
committed
feat: updated list's gotoAction to use fetch when redirect is false
1 parent 8209ccf commit 8ed1c42

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

@uportal/notification-list/src/components/NotificationList.vue

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,26 @@ export default {
7070
}
7171
},
7272
methods: {
73-
gotoAction(action) {
74-
const form = document.createElement('form');
75-
form.action = action.apiUrl;
76-
form.method = 'POST';
77-
form.target = '_blank';
78-
form.style.display = 'none';
79-
document.body.appendChild(form);
80-
form.submit();
73+
async gotoAction(action) {
74+
if (action.redirect) {
75+
const form = document.createElement('form');
76+
form.action = action.apiUrl;
77+
form.method = 'POST';
78+
form.target = '_blank';
79+
form.style.display = 'none';
80+
document.body.appendChild(form);
81+
form.submit();
82+
}
83+
else {
84+
const response = await fetch(action.apiUrl, {
85+
credentials: 'same-origin',
86+
method: 'POST',
87+
});
88+
89+
if (!response.ok || response.status !== 200) {
90+
throw new Error(response.statusText);
91+
}
92+
}
8193
},
8294
markAllAsRead() {
8395
this.gotoAction(this.markAllAsReadLink);

0 commit comments

Comments
 (0)