fix: callPluginApi unwrap response (TransformInterceptor wrapping)

This commit is contained in:
Kyryll O. 2026-06-12 17:53:48 +03:00
parent 3451a23e8e
commit de45ca428b
1 changed files with 8 additions and 1 deletions

View File

@ -162,10 +162,17 @@ export class CoreService {
}
async callPluginApi<T = any>(pluginId: string, path: string, body?: any): Promise<T> {
return this.fetchCore(`/api/plugins/rpc/${pluginId}/${path.replace(/^\//, '')}`, {
const res = await this.fetchCore(`/api/plugins/rpc/${pluginId}/${path.replace(/^\//, '')}`, {
method: 'POST',
body: body !== undefined ? JSON.stringify(body) : undefined,
});
if (res && typeof res === 'object' && res.success === true) {
if (res.data && typeof res.data === 'object' && res.data.success === true) {
return res.data.data as T;
}
return res.data as T;
}
return res as T;
}
async callAsService<T = any>(pluginId: string, path: string, body?: any): Promise<T> {