Form validation using React.js

Hello can someone help me on my ongoing project in react js. My problem is more on the validation of the user in registering his/her account but when I run the code it shows that it is already registered even if its new sample account.

const Register = () => {
  const navigate = useNavigate();
  const [firstName, setFirstName] = useState('');
  const [lastName, setLastName] = useState('');
  const [userName, setUserName] = useState('');
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');
  const [number, setNumber] = useState('');
  const [address, setAddress] = useState('');
  const [errorMessage, setErrorMessage] = useState('');

  const SwalE = withReactContent(Swal);

  const checkNewUser = async () => {
    const { data } = await axios.get(`${URL}/users`);
    const userFound = data.find((user) => user.userName === userName);
    if (userFound) {
    } else {
      icon: 'success',
      title: 'Successfully Registered',
      confirmButtonColor: "#435e39",

  const addUser = async () => {
    const model = {
      firstName: firstName,
      lastName: lastName,
      userName: userName,
      email: email,
      password: password,
      number: number,
      address: address
    const response = await`${URL}/users`, model);
    if (response) {{
        icon: 'error',
        title: 'Account Already Registered',
        confirmButtonColor: "#435e39",

  const validation = (e) => {
    if (firstName && lastName && userName && email && password && number && address) {
    } else {{
        icon: 'warning',
        title: 'Incomplete Fields',
        text: 'Please fill in all fields',
        confirmButtonColor: "#435e39",

Maybe I’m off (didn’t get a lot of sleep last night), but it seems like you’re having the Account Already Registered occur if the response object is truthy inside of the addUser function. But whether the user exists or not, there would still be a response object returned by your call you’re storing in the response variable. That would mean that it would always respond with ‘Account Already Registered’ when trying to add a new user.