diff --git a/api/projects/projects.go b/api/projects/projects.go index ea9ccab..3861387 100644 --- a/api/projects/projects.go +++ b/api/projects/projects.go @@ -24,8 +24,9 @@ func ApplyRoutes(r *gin.RouterGroup) { func AddProject(c *gin.Context) { var req AddProjectRequest - if err := c.BindJSON(&req); err != nil { + if err := c.ShouldBind(&req); err != nil { fmt.Println("error", err) + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } db := dbconfig.GetDb() @@ -39,9 +40,11 @@ func AddProject(c *gin.Context) { project.Twitter = req.Twitter project.Linkedin = req.Linkedin project.Owner = req.Owner + project.Image = req.Image err := db.Create(&project).Error if err != nil { fmt.Println("error", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{ diff --git a/api/user/types.go b/api/user/types.go index 7ff8292..6d3035e 100644 --- a/api/user/types.go +++ b/api/user/types.go @@ -1,6 +1,6 @@ package user type request struct { - username string `json:"username"` - walletAddress string `json:"username"` + Username string `json:"username"` + WalletAddress string `json:"walletAddress"` } diff --git a/api/user/user.go b/api/user/user.go index b936ca3..fef4fb6 100644 --- a/api/user/user.go +++ b/api/user/user.go @@ -98,7 +98,7 @@ func AssignWalletToUsername(c *gin.Context) { "error": "bad request", }) } - tx, err := instance.AssignAddressToUsername(auth, request.username, common.HexToAddress(request.walletAddress)) + tx, err := instance.AssignAddressToUsername(auth, request.Username, common.HexToAddress(request.WalletAddress)) if err != nil { logrus.Errorf("cannot assert type: publicKey is not of type *ecdsa.PublicKey") c.JSON(http.StatusInternalServerError, gin.H{