fix: fetch /api/unread read route for topbar drawer

require(['api']).api.get() targets NodeBB's v3 write API and 404s on
/api/v3/unread. Use a plain fetch against the read route /api/unread instead.
This commit is contained in:
2026-07-17 18:28:32 +02:00
parent c155437557
commit 070871c692
2 changed files with 13 additions and 9 deletions
+10 -6
View File
@@ -289,14 +289,18 @@
.off('show.bs.dropdown.westgateUnread')
.on('show.bs.dropdown.westgateUnread', '.wg-topbar [component="unread"]', function () {
const menuEl = this.querySelector('[data-wg-unread-menu]');
require(['api'], function (api) {
api.get('/unread', {}, function (err, data) {
if (err) {
renderUnreadMenu(menuEl, []);
return;
const relativePath = (window.config && window.config.relative_path) || '';
fetch(relativePath + '/api/unread', {
headers: { accept: 'application/json' },
}).then(function (res) {
if (!res.ok) {
throw new Error('unread fetch failed: ' + res.status);
}
return res.json();
}).then(function (data) {
renderUnreadMenu(menuEl, data && data.topics);
});
}).catch(function () {
renderUnreadMenu(menuEl, []);
});
});
}
+1 -1
View File
@@ -11,7 +11,7 @@ assert(
'client.js should fetch unread topics when the unread dropdown opens'
);
assert(
client.includes("api.get('/unread'"),
client.includes("'/api/unread'"),
'client.js should load the unread list from the /unread API'
);
assert(