Closed diogo24m closed 6 months ago
The toast message is always success even though the promise catches an error and the return http code was 409.
I have the following code:
const toastMessage = { pending: 'message.pending', success: 'message.general.success', error: 'message.general.error', } toast.promise( axios .post(`${process.env.REACT_APP_API_URL}/api/kiosk/${id}`, json) .then((response) => { console.log(response) }) .catch((error) => { console.error(error.response.data.error) }), toastMessage )
The container:
<ToastContainer position='bottom-center' autoClose={5000} hideProgressBar={false} newestOnTop closeOnClick rtl={false} pauseOnFocusLoss draggable pauseOnHover limit={3} theme={mode === 'system' ? systemMode : mode} />
On Network tab of the browser I can find this:
kiosk | 204 | preflight | Preflight | 0 B | 3 ms kiosk | 409 | xhr | main.fe76730….hot-update.js:129 | 957 B | 622 ms
Everything else works fine, the error is printed on the console, and the server receives the data just fine.
The server is expressjs. I'm on React v18.2.0, Toastify v10
It was missing a Promise.reject() when catching the error.
Promise.reject()
The toast message is always success even though the promise catches an error and the return http code was 409.
I have the following code:
The container:
On Network tab of the browser I can find this:
Everything else works fine, the error is printed on the console, and the server receives the data just fine.
The server is expressjs. I'm on React v18.2.0, Toastify v10