fix: ler resposta real do PATCH e logar body enviado/recebido para debug
This commit is contained in:
@@ -256,6 +256,9 @@ impl SupabaseClient {
|
||||
urlencoding::encode(id_fechamento)
|
||||
);
|
||||
|
||||
// Log do que está sendo enviado (debug)
|
||||
log::info!("[PATCH] url={} body={}", url, updates);
|
||||
|
||||
let resp = self
|
||||
.http
|
||||
.patch(&url)
|
||||
@@ -264,11 +267,18 @@ impl SupabaseClient {
|
||||
.json(updates)
|
||||
.send()?;
|
||||
|
||||
if resp.status().is_success() {
|
||||
let status = resp.status();
|
||||
if status.is_success() {
|
||||
// Ler a resposta real do Supabase (retorna o registro atualizado)
|
||||
if let Ok(ret) = resp.json::<serde_json::Value>() {
|
||||
log::info!("[PATCH] sucesso — resposta: {}", ret);
|
||||
} else {
|
||||
log::warn!("[PATCH] sucesso mas não conseguiu ler resposta");
|
||||
}
|
||||
Ok(serde_json::json!({ "ok": true, "id_fechamento": id_fechamento }))
|
||||
} else {
|
||||
let status = resp.status();
|
||||
let body = resp.text().unwrap_or_default();
|
||||
log::error!("[PATCH] HTTP {} body: {}", status.as_u16(), body);
|
||||
Err(SupabaseError::Api(format!(
|
||||
"HTTP {}: {}",
|
||||
status.as_u16(),
|
||||
|
||||
Reference in New Issue
Block a user