Skip to content

Instantly share code, notes, and snippets.

@alphanetEX
Created October 31, 2022 21:02
Show Gist options
  • Save alphanetEX/e753dd7f6432e3c46487631764d2168b to your computer and use it in GitHub Desktop.
Save alphanetEX/e753dd7f6432e3c46487631764d2168b to your computer and use it in GitHub Desktop.
stable request
lastProduct: (req, res) => {
console.log("ejecutando request");
db.Product.findAll({
include : ["Images"],
order: [[ ,'id' , 'DESC']],
})
.then(data => {
let object = data[0].dataValues;
let producto = {
id: object.id,
name: object.name,
typeId: object.typeId,
type: object.Type,
price: object.price,
discount: object.discount,
image: `http://localhost:3000/images/products/`+ object.Images[0].fileName,
description: object.description,
};
res.status(200).json( {
status:200,
producto,
detalle: "api/products/"+object.id,
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment