Answer the question
In order to leave comments, you need to log in
Why am I only getting the first product from the gorm go table?
I have a function
func GetProducts(c *gin.Context) {
var product models.Product
database.DB.Find(&product)
c.JSON(http.StatusOK, product)
}
Answer the question
In order to leave comments, you need to log in
Try like this
func GetProducts(c *gin.Context) {
var products []models.Product
database.DB.Find(&products)
c.JSON(http.StatusOK, products)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question