Soo's avatar
Level 2

navigate not working

Hello my friend , i want a add navigate when i add new change request i want to redirect to the change request liste , but i dont know why she doesn't work ,this is the code.

axiosClient
       .post("/change-requests/add",  formData, {
          headers: {
            'Content-Type': 'multipart/form-data'
          }
        })
        .then(({ data }) => {
          setChangeRequests(data.changeRequest);
          setShowModal(false); 
          navigate("/change-requests");
          showToast("Change Request Created Successfully!");
         
        })
       .catch((error) => {
        if (error.response && error.response.data && error.response.data.errors) {
          const finalErrors = Object.values(error.response.data.errors).reduce((accum, next) => [...accum, ...next], []);
          setError({ __html: finalErrors.join('<br>') });
        } else {
          setError({ __html: 'An unexpected error occurred.' });
        }
        console.error(error);
      });
    }
0 likes
1 reply
gych's avatar

Are you using React as separated SPA or React with Laravel and Inertia?

Please or to participate in this conversation.