I'm new to react native. I'm using fetch to get data from server. in this request url host name is dynamic.when i use it's not working. i tried lots of things none of them is working. here is my code.
registerCall = host => {
    var url = 'http://' + host + '/DashboardApi/public/SignIn';
    const username = this.state.Usrname;
    fetch(url, {
      method: 'POST',
      headers: new Headers({
        Accept: 'application/json',
        'Content-Type': 'application/json',
      }),
      body: JSON.stringify({
        username: username,
        password: this.state.password,
      }),
    })
      .then(response => {
        return response.json();
      })
      .then(result => {
        console.log(result);
        if (result == false) {
          Alert.alert('Wrong Username or Password!');
        } else {
          AsyncStorage.setItem('username', JSON.stringify(result[1]));
          this.props.navigation.navigate('Home');
        }
      })
      .catch(function(error) {
        alert('result:' + error);
      });  
};   
I'm getting this error
error TypeError: Network request failed
    at EventTarget.xhr.onerror (D:\React Native\dashboard_app\node_modules\whatwg-fetch\dist\fetch.umd.js:473)
    at EventTarget.dispatchEvent (D:\React Native\dashboard_app\node_modules\event-target-shim\dist\event-target-shim.js:818)
    at EventTarget.setReadyState (D:\React Native\dashboard_app\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:575)
    at EventTarget.__didCompleteResponse (D:\React Native\dashboard_app\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:389)
    at D:\React Native\dashboard_app\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:502
    at RCTDeviceEventEmitter.emit (D:\React Native\dashboard_app\node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189)
    at MessageQueue.__callFunction (D:\React Native\dashboard_app\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:425)
    at D:\React Native\dashboard_app\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112
    at MessageQueue.__guard (D:\React Native\dashboard_app\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:373)
    at MessageQueue.callFunctionReturnFlushedQueue (D:\React Native\dashboard_app\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111)

