title: Fetch API mode: no-cors assign then function variable
body: <p>Hello I created this code block, and i don't know how to assign then function variable.</p>
  
  <p><strong>Api Server:</strong> 192.168.1.109:8085</p>
  
  <p><strong>Nginx Client Server:</strong> 192.168.1.137:8086, 192.168.1.109:8086</p>
  
  <p>For Cors all my settings seem to be correct. I think :/.</p>
  
  <p>The main responsibility is to validate and capture data when fetching data with fetch. I can not print the response data from the screen even if I succeeded. Please save me . I was stack, Today 9. day in my life :(</p>
  
  <p><strong>httpd.conf</strong></p>
  
  <pre><code>Header always set Access-Control-Allow-Origin "*"
  Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
  Header always set Access-Control-Max-Age "1000"
  Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
  RewriteEngine On
  RewriteCond %{REQUEST_METHOD} OPTIONS
  RewriteRule ^(.*)$ $1 [R=200,L]
  &lt;IfModule mod_headers.c&gt;
  Header always set Access-Control-Allow-Credentials true
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Client Application codes for fetching data.
  <strong>device-controller.js</strong></p>
  
  <pre><code>angular
  .module('interface', ['loadingStatus'])
  .controller('DeviceController', DeviceController)
  .config(['$httpProvider', function($httpProvider) {
      //$httpProvider.defaults.withCredentials = true;
      //delete $httpProvider.defaults.headers.common['X-Requested-With'];
  }]);
  </code></pre>
  
  <p>function DeviceController($scope, $http){</p>
  
  <pre><code>$scope.postLogin  = async function (){
      const url = 'http://192.168.1.109:8085/register/login';
      const formData = new FormData();
      formData.append("usrname", "*******");
      formData.append("passwd", "********");
  
      const config = {
          headers: {
              'content-type': undefined
          },
          method: 'POST',
          //mode: 'cors', // if mode no-cors 
      };
  
      $http.post(url, formData, config)
          .then(function successCallback(response) {
              console.log(response);
              toastr.success('success');
          }, function errorCallback(response) {
              console.log(response);
              toastr.error('error');
          });
  };
  $scope.postLogin();
  
  
  $scope.zwnetGetDesc = async function zwnetGetDesc(){
      await fetch('http://192.168.1.109:8085/cgi/zcgi/networks//zwnet_get_desc', {
          credentials: 'same-origin',
          headers: {
              'user-agent': 'Mozilla/4.0 MDN Example',
              'content-type': 'text/xml'
          },
          method: 'POST',
          mode: 'no-cors'
      })
          .then(blob =&gt; blob.text())
          .then(data =&gt; {
              console.log(data);
              return data;
          })
          .catch(error =&gt; {
              console.log(error);
              return error;
          });
  };
  
  $scope.zwnetGetDesc();
  </code></pre>
  
  <p>};</p>
  
  <p><a href="https://ibb.co/ePchEc" rel="nofollow noreferrer">https://ibb.co/ePchEc</a> [header screenshot]
  <a href="https://ibb.co/jnQPSx" rel="nofollow noreferrer">https://ibb.co/jnQPSx</a> [xml response body]</p>
  
  <p>Gist Link: <a href="https://gist.github.com/umutyerebakmaz/073424a4195e75db482ac71e378e4408" rel="nofollow noreferrer">https://gist.github.com/umutyerebakmaz/073424a4195e75db482ac71e378e4408</a></p>