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:
co-authored by
Claude Sonnet 4.6
parent
27f4a2d7ec
commit
b0ca6804fa
@@ -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 = {
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user