Fix notes list not rendering — handle unwrapped API response
sw.api.ext() auto-unwraps the JSON response body, so the list
endpoint returns the array directly rather than {data: [...]}.
Use `res.data || res || []` pattern matching tasks surface.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -308,7 +308,8 @@
|
|||||||
} else {
|
} else {
|
||||||
res = await api.get('/notes');
|
res = await api.get('/notes');
|
||||||
}
|
}
|
||||||
var items = (res && res.data) || [];
|
var items = (res && res.data) || res || [];
|
||||||
|
if (!Array.isArray(items)) items = [];
|
||||||
// sort: pinned first, then by updated_at desc
|
// sort: pinned first, then by updated_at desc
|
||||||
items.sort(function(a, b) {
|
items.sort(function(a, b) {
|
||||||
if (a.pinned !== b.pinned) return b.pinned - a.pinned;
|
if (a.pinned !== b.pinned) return b.pinned - a.pinned;
|
||||||
|
|||||||
Reference in New Issue
Block a user