[英]How do I get the id of the created order
我正在使用帶有 Nuxt 的 Strapi,我想重定向到它在成功將訂單發布到 Strapi 后創建的新訂單。 我正在尋找的是 PHP 世界中的mysql_insert_id()
等價物。
try {
const neworder = await this.$strapi.$orders.create(this.neworder)
console.log(neworder)
if(neworder !== null) {
this.$router.push({ name:'order-id', params: neworder.id })
}
} catch (error) {
this.error = error
}
我可以在控制台日志上看到新的 id:
如何訪問返回的 id 並將其傳遞給this.$router.push
的參數? 我嘗試使用與控制台上顯示的相同的“id”,但沒有運氣。
我想到了。 我將保持打開狀態,以防它對其他人有所幫助。
重定向($router.push)應該是這樣的:
this.$router.push({ name:'order-id', params: {id: neworder.id }})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.