Fix JSON parse error on empty responses: handle empty body in API client and return message from saveSmtpConfig

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-29 11:12:13 -05:00
co-authored by Claude Sonnet 4.6
parent 27f4a2d7ec
commit b0ca6804fa
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -24,7 +24,8 @@ async function request<T>(path: string, options?: RequestInit): Promise<T> {
throw new ApiError(res.status, body.message || 'Error de servidor');
}
return res.json();
const text = await res.text();
return text ? JSON.parse(text) : ({} as T);
}
export const api = {
+1
View File
@@ -46,6 +46,7 @@ export class EmailOtpService {
create: { key: 'smtp_config', value: config as any },
update: { value: config as any },
});
return { message: 'Configuración SMTP guardada' };
}
async sendOtp(email: string): Promise<void> {