Here is my code snippet I'm trying to pass language_id
along with book create call somehow I'm getting an error
func Create(c *gin.Context) {
dbb := c.MustGet("db").(*gorm.DB)
book := Models.BookModel{
Title: c.PostForm("title"),
Author: c.PostForm("author"),
LanguageID: c.PostForm("language_id"),
}
dbb.Save(&book)
c.JSON(http.StatusCreated, gin.H{"status": http.StatusCreated, "message": "Book created successfully!", "bookId": book.ID})
}
error is
Cannot use 'c.PostForm("language_id")' (type string) as type int
any help that would be great thanks!
LanguageID: c.PostForm("language_id"),
Cannot use 'c.PostForm("language_id")' (type string) as type int
– deepu