douwen5690 2018-11-10 15:08
浏览 1151
已采纳

如何从gin中的前端获取数据?

To my shame, I have not been able to figure out how to get data from the frontend in Gin framework. In Django I get data So:

user=request.data.get('user')
print(user)

Everything is simple and understandable as day. How should I do it in gin?

user := c.Query("user")
user := c.Param("user")
user := c.Params.ByName("user")
user := c.PostForm("user")
println(user)//emptiness....
  • 写回答

4条回答 默认 最新

  • dongqiao8421 2018-11-15 20:31
    关注

    Server GIN can't handle routine default application/json requests from axios!!! What??? Requests should be sent as application/x-www-form-urlencoded. My decision in Vue project: Use vue-resource instead axios (axios.post=>this.$http.post) with option Vue.http.options.emulateJSON = true; in main.js

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 关于加载卡的问题有能知道这个要怎么处理吗?
  • ¥100 rtmpose姿态评估
  • ¥15 java 通过反射找路径下的类,打包后就找不到
  • ¥15 通联支付网上收银统一下单接口
  • ¥15 angular有偿编写,
  • ¥15 centos7系统下abinit安装时make出错
  • ¥15 hbuildex运行微信小程序报错
  • ¥15 关于#python#的问题:我知道这个问题对你们来说肯定so easy
  • ¥15 wpf datagrid如何实现多层表头
  • ¥15 为啥画版图在Run DRC会出现Connect Error?可我Calibre的hostname和计算机的hostname已经设置成一样的了。