目录axiOS-GET请求Gin-GET响应Vue-POST请求Gin-POST响应axios-GET请求 created() { console.log('
created() {
console.log('该组件要被加载成功了')
this.$axios({
url: "Http://127.0.0.1:8080/student/3",
method: "GET",
headers: {
// 'Content-Type': 'application/x-www-fORM-urlencoded'
'Content-Type': 'multipart/form-data'
}
}).then(response => {
console.log(response)
}
).catch(error => {
console.log(456)
console.log(error)
}
);
r.GET("/student/:ID", func(c *gin.Context) {
id := c.Param("ID")
var student Student
_ = c.ShouldBind(&student)
db.Preload("Teachers").Preload("IDCard").First(&student, "id=?", id)
c.JSON(200, gin.H{
"msg": student,
})
})
this.$axios({
url: "http://127.0.0.1:8080/test",
method: "post",
headers: {
'Content-Type':'application/x-www-form-urlencoded',
},
data: {
"name": "jeff",
"age": 18
}
}).then(response => {
console.log(response)
}
).catch(error => {
console.log(456)
console.log(error)
}
);
r.POST("/test", func(c *gin.Context) {
user := c.PostForm("name")
pwd := c.PostForm("age")
fmt.Println(user)
fmt.Println(pwd)
fmt.Println(c)
c.jsON(200, gin.H{
"msg": "成功!",
})
})
以上就是axios gin的GET和POST请求实现示例的详细内容,更多关于axios gin的GET和POST请求的资料请关注编程网其它相关文章!
--结束END--
本文标题: axios gin的GET和POST请求实现示例
本文链接: https://www.lsjlt.com/news/146142.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-05
2024-04-05
2024-04-05
2024-04-04
2024-04-05
2024-04-05
2024-04-05
2024-04-05
2024-04-04
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0