【发布时间】:2019-05-14 20:46:51
【问题描述】:
如何将用户重定向到他创建的帖子?我正在使用 mongo、express 和 vue
我的POST 请求如下所示:
async addOrder () {
if(this.name.length > 0 && this.address.length > 4 && this.city.length > 3) {
await PostsService.addOrder(
this.postData = {
order: this.cart,
name: this.name,
address: this.address,
city: this.city,
zip: this.zip,
country: this.countries,
summary: this.summary,
status: this.status,
})
this.$router.push({ name: 'EachOrder', params: { id: order.id} )
} else {
alert('Fill the form')
}
},
我知道,我需要以某种方式创建 ID,但在此发布请求之前我无权访问。有什么想法吗:D?
(对不起我的英语^^)
【问题讨论】:
-
PostsService.addOrder应该返回ID?您可以在那里捕获ID然后导航。 -
不,它不能 :/ 但我知道该怎么做 :D 谢谢你的帮助。
标签: javascript node.js mongodb vue.js axios