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:
+12
-8
@@ -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;
|
||||
}
|
||||
renderUnreadMenu(menuEl, data && data.topics);
|
||||
});
|
||||
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, []);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user