Мне нужно выполнить аутентификацию при входе в систему с помощью реакции нативной выборки пользователя в файле JSON, как показано ниже:
async componentDidMount() {
return fetch(
'https://gist.githubusercontent.com/MatheusCbrl/9504064f6605726886df412681fca376/raw/77666e642ee610cfab0aa690d543b3be2c07ba4e/teste.json'
)
.then(response => response.json())
.then(responseJson => {
// just setState here e.g.
this.setState({
users: responseJson,
});
})
.catch(error => {
console.error(error);
});
}
Я пытаюсь сделать что-то вроде этого:
_signin = async () => {
const{username, password} = this.state
if(username == ""){
Alert.alert(" ",'Por favor digite a Matrícula')
} else if(password == ""){
Alert.alert(" ",'Por favor digite o seu RG')
} else if (
username.response === this.state.username &&
password.response === this.state.password
) {
await AsyncStorage.setItem('Logado', '1');
this.props.navigation.navigate('Diurno');
console.log('entrou')
} else {
this.setState({ isVisible: true })
console.log('login inválido');
}
кто-нибудь может мне помочь?