J
J
JordanBelford2021-05-13 10:33:32
React
JordanBelford, 2021-05-13 10:33:32

Why is redirect not happening?

Good afternoon! The task is the following, with a successful request, you need to make a redirect, to solve this problem, I wrote this function:

const addNumberHandler = async () => {
        try {
            await axios.post('/newNumber/', obj, {
                headers: {
                    'Content-Type': 'application/json'
                }
            })
                .then(res => {
                    if (res.data.status === 201) {
                        return <Redirect to="/"/>;
                    }
                });
        } catch (e) {
            console.log(e);
        }
    }

The addition happens and the response from the server comes, but why doesn't the redirect work?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question