How to write request body containing component datas (buys) ?
August 16, 2021 at 1:36pmHow to write request body containing component datas (buys) ?
August 16, 2021 at 1:36pm (Edited 11 months ago)First, an exemple of coin added in strapi admin.
url:
http://localhost:1337/coins/1
{id: 1,name: "bitcoin",symbol: "btc",created_at: "2021-08-11T23:38:11.694Z",updated_at: "2021-08-13T21:10:16.681Z",buys: [{0: {id: 5,amount: 0.02,price: 40000}}]}
I made a front-end form to add new coin.
Below is the part of the function where I insert input datas.
I tested with only name and symbol and it works.
But when I try to create new coin with
buys
datas (which is a repeatable component) I cant figure out how to write request body?
Check commented lines.axios.post("http://localhost:1337/coins", {name: post.name,symbol: post.symbol,// buys: [{// 0: {// amount: post.amount, // --> response returns null// price: post.price, // --> response returns null// },// }]})
Thanks for your help.
Sorry if it's not the right place to ask such questions.
August 16, 2021 at 7:12pm