Skip to content

Commit 4f66927

Browse files
committed
Fix SDK 1.9.0 compatibility in queryApiText
1 parent 5c14a47 commit 4f66927

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/utils/sdk.mts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,14 @@ export async function queryApiText(
188188
): Promise<CResult<string>> {
189189
const opts = { __proto__: null, throws: false, ...options }
190190
try {
191-
const result = await sdk.getApi<CResult<string>>(path, {
191+
// SDK 1.9.0+ returns data directly when throws: true, or result object when throws: false.
192+
// Always throw on error, we'll wrap in CResult.
193+
const result = await sdk.getApi<string>(path, {
192194
responseType: 'text',
193-
throws: opts.throws,
195+
throws: true,
194196
})
195197

196-
if (result && typeof result === 'object' && 'ok' in result) {
197-
return result as CResult<string>
198-
}
199-
200-
// SDK returned direct string when throws: true succeeds.
198+
// Wrap in CResult for backward compatibility
201199
return { ok: true, data: result as string }
202200
} catch (e) {
203201
const message = `Error fetching ${opts.description || 'data'}: ${e instanceof Error ? e.message : String(e)}`

0 commit comments

Comments
 (0)