最初,消息字段(Strapi 可重复组件)将如下所示。"messages":[ { "from": "user1", "_id": "5f787348628eea0017b49f7e", "text": "happy hello world", "createdAt": "2020-10-03T12:49:12.052Z", "updatedAt": "2020-10-03T12:49:12.052Z", "__v": 0, "id": "5f787348628eea0017b49f7e" }]我想向可重复组件添加另一条消息:"messages":[ { "from": "user2", "text": "happy hello world" } ]当我通过 curl 放置它时:curl -i -X PUT \ -H "Content-Type:application/json" \ -d \'{ "messages":[ { "from": "shop", "text": "happy hello world" } ]}' \ 'https://myserver/mes/5f781bdd23e08f001732cdd8'它会覆盖之前的消息。如何在不丢失任何先前数据的情况下添加其他消息?
1 回答
慕容708150
TA贡献1831条经验 获得超4个赞
你必须像你一样用 PUT 发送所有数组。
{
"id": "5f781bdd23e08f001732cdd8",
"messages": [
{
"id": "5f787348628eea0017b49f7e",
"from": "user1",
"text": "happy hello world"
},
{
"from": "shop",
"text": "happy hello world"
}
]
}
看起来 Strapi 不知道你是想更新第一个,还是删除它,或者创建一个新的......
添加回答
举报
0/150
提交
取消