title: React-Native not able to connect to a Node.js server (Network request failed onerror)
body: <p>I am trying to make a simple React Native app able to send data to a Node.js server. </p>
  
  <p>Nonetheless I get a 'Network request failed' error...</p>
  
  <p>It is the first time I'm trying to implement this kind of project so I may have done a stupid mistake but it's been 2 days I've been unable to find</p>
  
  <p>Thanks for any help or advice!</p>
  
  <p>This is my app code: </p>
  
  <pre><code>import React from 'react'
  import {Text, View, TextInput, Button, StyleSheet, ImageBackground, Image, TouchableOpacity} from 'react-native' //import des components natifs
  import {StackNavigator } from 'react-navigation';
  
  const io = require('socket.io-client');
  let socket = io('https://localhost:8080');
  
  class Connexion extends React.Component{
      constructor(props){
          super(props);
   }
  
  validationConnexion(){
      fetch('https://localhost:8080', {
        method: 'POST',
        headers: {
          Accept: 'text/plain',
          },
      }).catch((error) =&gt; {             
          console.error(error);
          });
  }
  </code></pre>
  
  <p>On the backend side:</p>
  
  <pre><code>const express = require('express');
  const https = require('https')
  const socketio = require('socket.io');
  
  const app = express();
  const server = https.Server(app, function(req, res) {
     res.writeHead(200, {"Content-Type": "text/plain"});
     res.end();})
  const websocket = socketio(server);
  server.listen(8080, () =&gt; console.log('listening on *:8080'));
  
  // The event will be called when a client is connected.
  websocket.on('connection', (socket) =&gt; {
       console.log('A client just joined on', socket.id);
  });
  </code></pre>