title: 500 (Internal Server Error) transform node request to fetch request
body: <p>Hi i am using react native and i have a request in node with request js. I dont want to make the request on the server anymore. I want to do it at the frontend. I decided to use fetch.
  But when i do the same request on the frontend i get internal server error 500
  I only want the cookie which i get from the response.</p>
  
  <p><strong>This works in node:</strong></p>
  
  <pre><code>var request = require('request');
  
  
  var dataString2 = 'lmaction=doLogin&amp;username=XXX&amp;password=XXX';
  
  var options2 = {
      url: 'https://onlineservice.klarmobil.de/login',
      method: 'POST',
      headers:{
      'Host': 'onlineservice.klarmobil.de',
      'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0',
      'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
      'Accept-Language': 'de,en-US;q=0.7,en;q=0.3',
      'Referer': 'https://www.klarmobil.de/',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Connection': 'keep-alive',
      'Upgrade-Insecure-Requests': '1',
      'Cookie': '_gali=kundenlogin'
  },,
      body: dataString2
  };
  
  function callback2(error, response, body) {
      const cookie= response.headers['set-cookie'][0].split(";")[0] 
  }
  
  request(options2, callback2);
  </code></pre>
  
  <p><strong>And this is my code in react native:</strong></p>
  
  <pre><code>fetch('https://onlineservice.klarmobil.de/login', {
      method: 'POST', // or 'PUT'
      body: 'lmaction=doLogin&amp;username=xxx&amp;password=xxx'
      headers:{
          'Host': 'onlineservice.klarmobil.de',
          'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0',
          'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
          'Accept-Language': 'de,en-US;q=0.7,en;q=0.3',
          'Referer': 'https://www.klarmobil.de/',
          'Content-Type': 'application/x-www-form-urlencoded',
          'Connection': 'keep-alive',
          'Upgrade-Insecure-Requests': '1',
          'Cookie': '_gali=kundenlogin'
      }
    })
    .catch(error =&gt; console.log('Error:', error))
    .then((res)=&gt;{
      console.log(res)
      const cookie= response.headers['set-cookie'][0].split(";")[0] 
      console.log(cookie)
    })
  </code></pre>
  
  <p>Somebody can help me?</p>