react-toastify icon indicating copy to clipboard operation
react-toastify copied to clipboard

react tostify after post request

Open bhargavamamidi opened this issue 4 years ago • 1 comments

Hey guys,

I wanna call a toast after a POST request in ".then" method but it doesn't work. On a GET request it works fine:

toast.configure() const notify = (message) => toast(message);

handleFilter() { setAxiosHeaders() axios .get('/api/v1/desks/', { params: { date: this.state.resDate, }, }) .then(response => { this.setState({ desks: response.data }); },notify("aktualisiert!")) }

But when I do this it doesnt work and I don't know why. There are no errors but I don't see the notify toast:

createReservation(id){ setAxiosHeaders() axios .post('/api/v1/desks', { reservation: { date: this.state.resDate, desk_id: id } }) .then(() => { this.setState({ resDate: new Date() }), notify("aktualisiert!"); }) };

PLEASE REFER FOR MORE DETAILS: https://github.com/fkhadra/react-toastify/issues/526

bhargavamamidi avatar Jan 22 '22 11:01 bhargavamamidi

It would be helpful if you could show formatted code with backticks like this:

``` // code goes here ```

Does your network request actually go through? Do you actually get a response back? What does the network tab of your devtools show? Does it throw errors?

MoltenCoffee avatar Jan 22 '22 11:01 MoltenCoffee