diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-07-08 09:11:45 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-07-08 09:11:45 +0530 |
commit | 165d47723a484ba84acf13d62f7ae8e4f1392347 (patch) | |
tree | 1cf092e8aa05e5037e9cd8a6f4bf2dd1696ef729 /server/router/items.go | |
parent | 177427b5821a67e141236e6aeb4db12d76b050a0 (diff) |
polished how POST requests work on both front and back end
Diffstat (limited to 'server/router/items.go')
-rw-r--r-- | server/router/items.go | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/server/router/items.go b/server/router/items.go index 540fdf3..82f86ec 100644 --- a/server/router/items.go +++ b/server/router/items.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" "net/http" - "strconv" + //"strconv" db "github.com/MikunoNaka/openbills/database" ) @@ -23,21 +23,7 @@ func getAllItems(ctx *gin.Context) { } func registerItem(ctx *gin.Context) { - // extract data not string - price, _ := strconv.ParseFloat(ctx.Query("price"), 64) - gst, _ := strconv.ParseFloat(ctx.Query("gst"), 64) - cat := "cat coming soon" - brand := "brand coming soon" - - item := db.Item { - Model: ctx.Query("model"), - Description: ctx.Query("desc"), - UnitPrice: price, - HSN: ctx.Query("hsn"), - TotalGST: gst, - Category: cat, - Brand: brand, - } - - db.RegisterItem(item) + var newItem db.Item + ctx.Bind(&newItem) + db.RegisterItem(newItem) } |