Axios (in React-native) not calling server in localhost : <p>I'm building a really easy api and react-native application. The server works well (tested with PostMan) but the application doesn't call the server.  It blocks when axios has to send the post request (see below).</p>

<p>I'm desperate :-( Loosing too mush time in it. Please, if you can help me...</p>

<p>Here is my code LogIn page. It dispatch the action creator (working with redux) giving email and password:</p>

<pre><code>...
const LogIn = React.createClass({
  submitLogin() {
    // log in the server
    if (this.props.email !== '' &amp;&amp; this.props.psw !== '') {
      if (this.props.valid === true) {
        this.props.dispatch(logIn(this.props.email, this.props.psw));
      } else {
        this.props.dispatch(errorTyping());
      }
    }
  },
...
</code></pre>

<p>email and password are weel retrieved and sent to the action creator:</p>

<pre><code>import axios from 'axios';
import { SIGNIN_URL, SIGNUP_URL } from '../api';
// import { addAlert } from './alerts';
exports.logIn = (email, password) =&gt; {
  return function (dispatch) {    
    console.log(email);
    console.log(password);
    console.log(SIGNIN_URL);
    return axios.post(SIGNIN_URL, { email, password })
    .then(
      (response) =&gt; {
        console.log(response);
        const { token, userId } = response.data;
        dispatch(authUser(userId));
      }
    )
    .catch(
      (error) =&gt; {
        console.log('Could not log in');
      }
    );
  };
};
const authUser = (userId) =&gt; {
 return {
 type: 'AUTH_USER',
 userId
 };
};
...
</code></pre>

<p>The three console.log() before axios show the data in the correct way. SIGNIN_URL is exactly the same I use in postman. ...but axios doesn't call.</p>

<p>Just to give all the cards, this is my store:</p>

<pre><code>import thunk from 'redux-thunk';
import { createStore, compose, applyMiddleware } from 'redux';
import { AsyncStorage } from 'react-native';
import { persistStore, autoRehydrate } from 'redux-persist';
import reducer from '../reducer';
const defaultState = {};
exports.configureStore = (initialState = defaultState) =&gt; {
 const store = createStore(reducer, initialState, compose(
 applyMiddleware(thunk),
 autoRehydrate()
 ));
 persistStore(store, { storage: AsyncStorage });
 return store;
};
</code></pre>

<p>There's no error message in the debugger (but the one given by the axios call ('Could not log in')</p>

<p>I'm on windows 10, with:</p>

<pre><code>"axios": "^0.15.3",
"react": "15.4.2",
"react-native": "0.38.0",
"redux": "^3.6.0"
</code></pre>

<p>The call fails even when I prepare a simple GET call and the server is supposed to give back a simple message (tested with postman and browser):</p>

<pre><code>exports.test = () =&gt; {
  return function () {
    return axios.get('https://localhost:3000/v1/test')
    .then(
      (response) =&gt; {
        console.log(response);
      }
    )
    .catch(
      (error) =&gt; {
        console.log('error');
      }
    );
  };
};
</code></pre>

<p>Last, I tryed also to modify the call adding a header as the following, because the api is coded to accept json:</p>

<pre><code>const head = {
  headers: { 'Content-Type': 'application/json' }
};

exports.test = () =&gt; {
  return function () {
    return axios.get('https://api.github.com/users/massimopibiri', head)
    .then(
      (response) =&gt; {
        console.log(response);
      }
    )
    .catch(
      (error) =&gt; {
        console.log('error');
      }
    );
  };
};
</code></pre>

<p>but even this didn't work. hope somebody can help me. Other similar issues didn't.</p>
