Answer the question
In order to leave comments, you need to log in
How do I get the body that was submitted by gin gonic golang?
package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
func main() {
fmt.Println("Hello, world!")
r := gin.Default()
r.POST("/", func(c *gin.Context) {
body := c.Request.Body
c.JSON(200,body);
})
r.Run(":8080");
}
{
"email": "[email protected]",
"password": "test"
}
{}
Answer the question
In order to leave comments, you need to log in
Try like this
jsonDataBytes, err := ioutil.ReadAll(c.Request.Body)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question