diff --git a/routes/detalleLibro.js b/routes/detalleLibro.js index 9e13643..893d12c 100644 --- a/routes/detalleLibro.js +++ b/routes/detalleLibro.js @@ -19,29 +19,31 @@ function query(consulta) { app.get('/libroDetalle', async(req, res) => { - + let data = req.query; if( typeof( data.idLibro ) === 'undefined' ){ res.status(400).json({error: true, msj: 'Falta el ID del libro como parametro'}); return; } - console.log(` Este es el id: ${data.idLibro}`); - let sqlString = `SELECT * from Libro where idLibro=${data.idLibro}`; - console.log(` Esta es la cadena : ${sqlString}`); - let respuestaSql = await query(sqlString); - - respuestaSql = respuestaSql[0]; - - if(respuestaSql.length === 0 ){ - res.status(400).json({error: true, msj: 'No se encontro el libro solicitado'}); - return; - } - try{ - res.status(200).json({error:false, msj: 'exito', data: respuestaSql}) + + console.log(`Se hizo una peticion ${data.idLibro}`); + console.log(` Este es el id: ${data.idLibro}`); + let sqlString = `SELECT * from Libro where idLibro=${data.idLibro};`; + console.log(` Esta es la cadena : ${sqlString}`); + let respuestaSql = await query(sqlString); + + respuestaSql = respuestaSql[0]; + + if(respuestaSql.length === 0 ){ + res.status(400).json({error: true, msj: 'No se encontro el libro solicitado'}); + return; + } + + res.status(200).json({error:false, msj: 'exito', datos: respuestaSql}) } catch(error){ - res.status(400).json({error: true, msj: 'No se pudo obtener la imagen', desc: error}); + res.status(400).json({error: true, msj: 'No se pudo obtener la el libro', desc: error}); return; } diff --git a/routes/libroImagen.js b/routes/libroImagen.js index 5be7378..a5fb956 100644 --- a/routes/libroImagen.js +++ b/routes/libroImagen.js @@ -19,6 +19,7 @@ function query(consulta) { app.get('/libroImagen', async(req, res) => { + console.log(`Entro a imagenes`); let data = req.query; if( typeof( data.idLibro ) === 'undefined' ){