jeudi 1 août 2019

React native error : Statement if does not work

when I want to compare the data entered by user with the data in the database I encounter a problem Unexpected token before the line of if(username == item.username && password == item.password) {.

please, how can I solve this problem? thank you

    login = (username,password) => {
        if (username === null || password === null) {
            alert("Veuillez remplir les champs !");
        }else{
        state ={
        data:[]
        }

        fetchData= async()=>{
            const response = await fetch('http:192.168.42.80:4545/authentification/:username/:password');
            const users = await response.json();
            this.setState({data: users});
        }
        function componentDidMount(){
          this.fetchData();
        }

        <FlatList
            data={this.state.data}
            keyExtractor={(item,index) => index.toString()}
            if(username == item.username && password == item.password) {
                alert(" connecter");
            }else{
                alert("non connecter");
            }
        />

    }
    }

I want to compare between the login and password entered by the user and the information stored in the database

Aucun commentaire:

Enregistrer un commentaire