Debug: Agregar logging extensivo en servidor y cliente
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m6s

- Logs en useLotes() para ver cuándo se llama
- Logs en fetchLotes() para rastrear el flujo
- Logs en API /api/lotes para ver requests del servidor
- Todos los logs con emojis para fácil identificación:
  🔵 = Cliente/Composable
  🟦 = Servidor/API
   = Errores
This commit is contained in:
2025-11-21 23:39:11 -06:00
parent 2ca062b9e0
commit b0b179d945
2 changed files with 13 additions and 1 deletions

View File

@@ -31,8 +31,10 @@ export interface TrazabilidadRow {
}
export const useLotes = () => {
console.log('🔵 useLotes: Composable llamado, process.client:', process.client)
// useToast solo funciona en el cliente, no en SSR
const toast = process.client ? useToast() : null
console.log('🔵 useLotes: Toast inicializado:', !!toast)
// =====================================================
// FUNCIONES PARA LOTES
@@ -46,6 +48,7 @@ export const useLotes = () => {
limit?: number
offset?: number
}) => {
console.log('🔵 fetchLotes: Iniciando, filtros:', filtros)
try {
const query = new URLSearchParams()
if (filtros?.tipo) query.append('tipo', filtros.tipo)
@@ -54,12 +57,15 @@ export const useLotes = () => {
const queryString = query.toString()
const url = `/api/lotes${queryString ? `?${queryString}` : ''}`
console.log('🔵 fetchLotes: URL construida:', url)
console.log('🔵 fetchLotes: Llamando a useFetch...')
const { data, error } = await useFetch<{
success: boolean
data: Lote[]
count: number
}>(url)
console.log('🔵 fetchLotes: useFetch completado, data:', !!data.value, 'error:', !!error.value)
if (error.value) {
throw new Error(error.value.message || 'Error obteniendo lotes')