Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
1.6 kB
1
Indexable
Never
const getUserData = () => {

        axios.get("http://10.0.2.2:3000/users")
            .then(res => {
                const length = res.data.length
                setUsers(res.data)
                for (let i = 1; i <= length; i++) {
                    axios.get("http://10.0.2.2:3000/users", { params: { id: i } })
                        .then(res => {
                            console.log("masuk ",i)
                            users.map(user => {
                               //kenapa yang ini masuk pas klik ke dua ya? kenapa nga dari klik pertama uda masuk?
                                if (email == user.email && password == user.password) {
                                    console.log("email benar")
                                    navigation.navigate("Home")

                                } else {
                                    if (emailErrorMessage.text == "") {
                                        setEmailErrorMessage({ ...emailErrorMessage, text: "Please Input Email" })
                                    }else if(email != user.mail ){
                                        setEmailErrorMessage({ ...emailErrorMessage, text: "Input Email and Password field" })
                                    }

                                    setEmailBorder({ ...emailBorder, borderWidth: 1, borderColor: "red" })
                                }
                            })


                        })
                        .catch(error => console.log(error));
                }
            })

            .catch(error => console.log(error));


    }