Fix: use data.data.item instead of data.item for upload response

EmDash API wraps success responses as { data: { item: ... } },
not { item: ... }. This was causing "Upload failed: no item returned"
even when the upload actually succeeded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kunthawat Greethong
2026-05-04 11:58:35 +07:00
parent 8a6e268606
commit 65c876393c

View File

@@ -1257,8 +1257,8 @@ export function renderToolbar(config: ToolbarConfig): string {
return r.json(); return r.json();
}) })
.then(function(data) { .then(function(data) {
if (!data.item) throw new Error("Upload failed: no item returned"); if (!data.data || !data.data.item) throw new Error("Upload failed: no item returned");
var item = data.item; var item = data.data.item;
selectMediaItem(item, annotation, element, imgEl); selectMediaItem(item, annotation, element, imgEl);
}) })
.catch(function(err) { .catch(function(err) {