Spaces:
Runtime error
Runtime error
| const Glucosa = require("../models/glucosa.js"); | |
| /** | |
| * @description Obtener todos los registros de glucosa de un usuario | |
| * | |
| * @param {import("express").Request} req | |
| * @param {import("express").Response} res | |
| */ | |
| async function getGlucosaByIdUser(req, res) { | |
| const userId = req.params.iduser; | |
| try { | |
| const registros = await Glucosa.find({ iduser: userId }); | |
| if (registros.length == 0) { | |
| res.json({}); | |
| } | |
| res.json(registros); | |
| } catch (error) { | |
| res | |
| .status(500) | |
| .json({ error: "Error al obtener los registros de glucosa" }); | |
| } | |
| } | |
| /** | |
| * @description Registra un dato de glucosa | |
| * | |
| * @param {import("express").Request} req | |
| * @param {import("express").Response} res | |
| */ | |
| async function postOneRegisterGlucosa(req, res) { | |
| try { | |
| await Glucosa.create(req.body); | |
| res.json({ message: "Ok, datos ingresados" }); | |
| } catch (error) { | |
| res.status(500).json({ error: "Error al ingresar el registro de glucosa" }); | |
| } | |
| } | |
| module.exports = { | |
| getGlucosaByIdUser, | |
| postOneRegisterGlucosa, | |
| }; | |