title: React Native / Expo : Fetch throws “Network request failed”
body: <p>I saw several posts on the subject but without result. I have on the one hand a form which collects information (name, first name etc) then saves it in database (mongodb). Everything works when I use postman to send my information via the route / signup, i can see my new user in mongodb. but when i'm starting the app on Expo he throw me "Network request failed".</p>
  
  <p>Frontend fetch : </p>
  
  <pre class="lang-js prettyprint-override"><code>submitForm = () =&gt; {
    var signupData = JSON.stringify({
      first_name: this.state.firstName,
      last_name: this.state.lastName,
      email: this.state.email,
      password: this.state.password
    });
  
    fetch(`https://localhost:3000/signup`, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: signupData
    })
      .then(response =&gt; {
        console.log(response);
        return response.json();
      })
      .then(data =&gt; {
        if (data.result) {
          this.props.handleUserValid(
            this.state.firstName,
            this.state.lastName,
            this.state.email,
            data.user.token
          );
          this.props.navigation.navigate("Account");
        }
      })
      .catch(error =&gt; {
        console.error(error);
      });
  };
  
  </code></pre>
  
  <p>And Backend route : </p>
  
  <pre class="lang-js prettyprint-override"><code>router.post("/signup", function(req, res, next) {
    var salt = uid2(32);
  
    console.log("Signup is running...");
    const newUser = new userModel({
      first_name: req.body.first_name,
      last_name: req.body.last_name,
      email: req.body.email,
      password: SHA256(req.body.password + salt).toString(encBase64),
      token: uid2(32),
      salt: salt
    });
    newUser.save(function(error, user) {
      console.log("LOG: user", user);
      res.json({ result: true, user });
    });
  });
  
  module.exports = router;
  </code></pre>
  
  <p>And here is a screenshot of the error</p>
  
  <p><a href="https://i.stack.imgur.com/zuOdH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zuOdH.png" alt="enter image description here"></a></p>
  
  <p>Again when using Postman, the fetch is working good, my console log is printed and the user added to my data base. 
  Thanks for the help.</p>
  
  <p><strong>-- EDIT --</strong> </p>
  
  <p>I launched the application in a web browser via Expo and everything works perfectly. My sign in / sign up pages and my account page. But on my phone it's not working (IOS), it's a network problem from my phone (maybe a certificate problem, wrong IP ?) </p>
  
  <p>if you have an idea i'm interested, i've been stuck on it for 2 days</p>