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

@@ -10,16 +10,21 @@ import { getLotes } from '../../utils/queries'
* - offset: offset para paginación
*/
export default defineEventHandler(async (event) => {
console.log('🟦 API /api/lotes: Request recibido')
try {
const query = getQuery(event)
console.log('🟦 API /api/lotes: Query params:', query)
const filtros = {
tipo: query.tipo as string | undefined,
limit: query.limit ? parseInt(query.limit as string) : undefined,
offset: query.offset ? parseInt(query.offset as string) : undefined,
}
console.log('🟦 API /api/lotes: Filtros procesados:', filtros)
console.log('🟦 API /api/lotes: Llamando a getLotes...')
const lotes = await getLotes(filtros)
console.log('🟦 API /api/lotes: Lotes obtenidos:', lotes.length)
return {
success: true,
@@ -27,7 +32,8 @@ export default defineEventHandler(async (event) => {
count: lotes.length,
}
} catch (error: any) {
console.error('Error obteniendo lotes:', error)
console.error('❌ API /api/lotes: Error:', error.message)
console.error('❌ API /api/lotes: Stack:', error.stack)
throw createError({
statusCode: 500,
statusMessage: 'Error obteniendo lotes',