i need help updating database data in a reactmap list by properly attaching a url request

You already iterate on your products list, so you have access to product id.

deleteProduct = (id) => {
    let url = `http://localhost:3001/products/${id}`;
    return axios.delete((url)).then(response => {
      // refresh the data

this.state.productData.map(product => (
    <button type="button" onClick={() => this.props.deleteProduct(product.id)}>Delete</button>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top