title: Net Core Web Api not reachable from React Native
body: <p>I'm trying to develop a react native mobile app.
  I'm at the begin of the project and I'm already stuck.</p>
  
  <p>I created in VS 2019 a new Api Web Application.
  I'm trying to call WeatherForecastController (created from visual studio).</p>
  
  <p>I edited the startup.cs in order to avoid CORS issue.</p>
  
  <pre><code>public class Startup
  {
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          //services.AddCors();
          services.AddControllers();
          services.AddMvc();
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
  
          app.UseCors(builder =&gt;
          {
              builder.AllowAnyOrigin()
              .AllowAnyHeader()
              .AllowAnyMethod();
          });
  
          app.UseHttpsRedirection();
  
          app.UseRouting();
  
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllers();
          });
      }
  }
  </code></pre>
  
  <p>I installed axios in my React Native Projects.</p>
  
  <p>And this is how I call my api:</p>
  
  <pre><code>componentDidMount() {
  axios.get('http://localhost:55622/weatherforecast').then(function (response) {
    console.log("POST RESPONSE: " + JSON.stringify(response));
  });
  </code></pre>
  
  <p>}</p>
  
  <p>The error I receive is:</p>
  
  <pre><code>[Unhandled promise rejection: Error: Network Error]
  - node_modules\axios\lib\core\createError.js:15:17 in createError
  - node_modules\axios\lib\adapters\xhr.js:80:22 in handleError
  - node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
  - node_modules\react-native\Libraries\Network\XMLHttpRequest.js:574:29 in setReadyState
  - node_modules\react-native\Libraries\Network\XMLHttpRequest.js:388:25 in __didCompleteResponse
  - node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
  - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
  - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
  - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
  - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
  * [native code]:null in callFunctionReturnFlushedQueue
  </code></pre>
  
  <p>I tried in both http and https ways.</p>
  
  <p>I also tried to call some public apis like '<a href="https://facebook.github.io/react-native/movies.json" rel="nofollow noreferrer">https://facebook.github.io/react-native/movies.json</a>' and it works correctly.</p>
  
  <p>Call the same url from postman, it works correctly.</p>
  
  <p><a href="https://i.stack.imgur.com/e0BIk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e0BIk.png" alt="enter image description here"></a></p>
  
  <p>I'm using .Net Core 3.0 
  and here are the dependencies of my react native project:</p>
  
  <pre><code>  "dependencies": {
  "@expo/samples": "~36.0.0",
  "@expo/vector-icons": "~10.0.0",
  "@react-navigation/web": "~1.0.0-alpha.9",
  "axios": "^0.19.1",
  "expo": "~36.0.0",
  "expo-asset": "~8.0.0",
  "expo-constants": "~8.0.0",
  "expo-font": "~8.0.0",
  "expo-image-picker": "~8.0.0",
  "expo-permissions": "~8.0.0",
  "expo-web-browser": "~8.0.0",
  "galio-framework": "^0.6.3",
  "react": "~16.9.0",
  "react-dom": "~16.9.0",
  "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
  "react-native-gesture-handler": "~1.5.0",
  "react-native-maps": "0.26.1",
  "react-native-reanimated": "~1.4.0",
  "react-native-screens": "2.0.0-alpha.12",
  "react-native-signalr": "^1.0.6",
  "react-native-web": "~0.11.7",
  "react-navigation": "~4.0.10",
  "react-navigation-stack": "~1.10.3",
  "react-navigation-tabs": "~2.6.2",
  "react-redux": "^7.1.3",
  "redux": "^4.0.5",
  "redux-thunk": "^2.3.0"
  </code></pre>
  
  <p>}</p>
  
  <p>Could you please help me to find a way to solve this problem?
  Thank you in advance.</p>