I have been having trouble with my delete requests not working in Firefox with only info given is "error Request aborted". All other requests are working fine but on Firefox, the delete request is not working. I tested it on chrome and it works fine.
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import axios from 'axios';
const Buyer = props => (
<tr>
<td>{props.buyer.firstName} {props.buyer.lastName}</td>
<td>
<Link to={"/buyeredit/"+props.buyer._id}>edit</Link> | <a href="/buyer" onClick={() => { props.deletebuyer(props.buyer._id) }}>delete</a>
</td>
</tr>
)
export default class BuyerList extends Component {
constructor(props) {
super(props);
this.deletebuyer = this.deletebuyer.bind(this);
this.state = {buyers: []};
}
componentDidMount() {
axios.get('http://localhost:5000/buyer/')
.then(response => {
this.setState({ buyers: response.data });
})
.catch((error) => {
console.log(error);
})
}
deletebuyer(id) {
axios.delete('http://localhost:5000/buyer/'+id)
.then(res => console.log(res.data))
.catch(err => console.log("Oops, there was an error with deleteing please fix this asap, thx only works in chrome for some reason :"+err));
this.setState({
buyers: this.state.buyers.filter(el => el._id !== id)
});
}
buyerList() {
return this.state.buyers.map(currentbuyer => {
return <Buyer buyer={currentbuyer} deletebuyer={this.deletebuyer} key={currentbuyer._id}/>;
})
}
Edit: I have also tested the request in postman and it works perfectly.
curl
? If yes, please attach the screenshot or let me know the result whether it works or not. – Vtarj