【发布时间】:2021-10-13 02:02:08
【问题描述】:
我有以下代码...
const createThenReference = async () => {
return await axios.post('http://localhost:1337/firsts', {
name: "Jeremy"
})
.then(async (res)=>{
await axios.post('http://localhost:1337/seconds', {
name: "Jonathan",
first: res.data
})
.then((res)=>{console.log(res)})
.catch((err)=>{console.log(err)})
})
.catch((err)=>{console.log(err)})
}
每个表的字段如下...
First = { name: String, second: Relationship }
Second = { name: String, first: Relationship }
我想要实现的是,在创建 firsts 条目后,会在 seconds 内创建一个新条目,并引用回 firsts 在 1 对 1 引用中。
我已经成功地引用了已经以类似方式创建的项目,只需将它们传递到有效负载中的相应字段。但是,当它最近创建时,我遇到了问题。 -- 我找不到任何文档甚至谈到从前端创建引用。
【问题讨论】:
标签: strapi