diff --git a/src/webapi/_defhttp_shim.ts b/src/webapi/_defhttp_shim.ts index ab7854c..dccaf16 100644 --- a/src/webapi/_defhttp_shim.ts +++ b/src/webapi/_defhttp_shim.ts @@ -47,11 +47,34 @@ function cleanQuery(data: Record | undefined): Record(resp: { code: number; msg?: string; data: T | null }): Promise { if (resp.code !== 200) { throw new Error(`API code=${resp.code}: ${resp.msg ?? ''}`) } + if (resp.data === null || resp.data === undefined) { + // JNPF POST create-type 成功无 data → 返 stub 防 TypeError. + // 兼容所有调用方 cast `{code?, msg?, id?, data?}` 类型断言. + return { code: resp.code, msg: resp.msg, id: undefined } as unknown as T + } return resp.data as T }