'Possible Unhandled Promise Rejection (id: 0): ReferenceError: error is not defined

//LoginScreen.js

import signIn from "amplify-communication"
    
  const LoginScreen = props => {
    function _signIn(username, password){
        const request = signIn(username, password);
        if(request.isCommited)
           console.log("User is Signed In");
        else
           console.log("Error Signing In", request.message);
        
       }
    }

// amplify-communication.js
import { Auth } from "aws-amplify";
export async function signIn(_username, _password) {
    try {
        var user = await Auth.signIn(_username, _password);
    } catch (error) {
        console.log('Error Signing in');
    }
    finally {
        return {
            isCommitted: error ? false : true,
            message: error,
            payload: user
        }
    }
}

I have separate file for communicating with Amplify. I am returning an object with different keys. On running the code it shows me following warnings.

1 - Possible Unhandled Promise Rejection (id: 0): ReferenceError: error is not defined ReferenceError: error is not defined

2- Using an insecure random number generator, this should only happen when running in a debugger without support for crypto.getRandomValues



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source