Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何在React Native中进行API登录身份验证_React Native_Api_Authentication - Fatal编程技术网

React native 如何在React Native中进行API登录身份验证

React native 如何在React Native中进行API登录身份验证,react-native,api,authentication,React Native,Api,Authentication,我不确定如何使用电子邮件和密码进行基本的api登录验证。我被困在这里了。如果有人能帮忙。这是我的密码: class LoginScreen extends Component { constructor(){ super(); this.state = { email: '', password: '', result: false, }

我不确定如何使用电子邮件和密码进行基本的api登录验证。我被困在这里了。如果有人能帮忙。这是我的密码:

class LoginScreen extends Component {

  constructor(){
           super();
           this.state = {
            email: '',
            password: '',
            result: false,
           }
       }

    _userLogin() {
         var email = this.state.username;
         var password = this.state.password;
         if (email && password) { // if validation fails, value will be null
           fetch("https://URL/api/login", {
             method: "POST",
             headers: {
               'Accept': 'application/json',
               'Content-Type': 'application/json'
             },
             body: JSON.stringify({
               username: email,
               password: password,
             })
           })
           .then((response) => response.json())
           .then((responseData) => {
             console.log(responseData);
             AlertIOS.alert(
               "Login Success!"
             ),
             this._onValueChange(STORAGE_KEY, responseData.id_token)
           })
           .done();
           renderResults();
         }
       }

       handleEmail = (text) => {
             this.setState({ email: text })
       }

       handlePassword = (text) => {
             this.setState({ password: text })
       }

然后是如何在输入字段和按钮中使用它。

请在问题中添加更多详细信息提及您需要做什么我需要进行基本的api登录验证,需要有人向我演示如何使用,我不确定这是否有效。然后,如何在电子邮件/传递字段和按钮中使用它您使用的导航库是什么?React navigation嘿,搜索带有一些用户登录功能的基本React本机教程。如果你对具体细节有疑问,可以在这里询问。