Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29601

Axios POST method: Network Error - React Native

$
0
0

When i send request with my Google Cloud address from postman its ok but from android studio/react-native/axios its give an error.

[Error: Network Error]

This is my code:

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

handleLoginUser(){
    const { email, password } = this.state;
    this.setState({ error: '', loading: true });

    axios.post("https://serverip/users/login",
        {
            'email': 'email',
            'password': 'password'
        },
        {
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json; charset=utf-8',
            },
        }
    )
    .then(response => {
        console.log(response);
        return response.json();})
    .then(data => {
        if (result.success){
            alert("Login successful");
        }
        else
            alert("Unable to Login");
        })
    .catch((error) => {
      console.log(error);
    });
}

Thanks for your helps.


Viewing all articles
Browse latest Browse all 29601

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>