I'm fairly new to React development. In the shopping application that I'm developing, I'm trying to send a post request through a button to my rest services to add a product to the cart. I've added the axios library to perform this. Since all the online tutorials get the info to the requests through forms I was wondering how do I collect the information I got from an earlier get request and send it back as a post request to another data table. The following is my approach which does not work.
<button onClick={this.add.bind(this,this.state.groups.map(group => <div key={group.id}>{group.name}</div> ))} className="flex-c-m size1 bg4 bo-rad-23 hov1 s-text1 trans-0-4"> </button> the post request config method looks something like this
add() { axios({ method: 'post', url: '/api/cart', body: { productid: '', productname: '' } }); } Please help me in figuring this out. Thanks in advance.