title: fetch() json from php
body: <p>I've got a I've got a simple fetch request. I'm not much of an expert in promises and asynch code but from what I understand fetch url sends a request to open/get/post an url and returns a promise (response) of delivering that content. Qhen that content is fetched THEN I can parse it in a text (response.text() ) the parsed text/json, whatever, is then passed to another function as data and here processed</p>
  
  <p>** JS CODE **</p>
  
  <pre><code>fetch(url).then(function(response) {
      console.log(typeof(response));
      return response.text();
  }).then(function(data) {
      console.log('data ', data);
  }).catch(function(err) {
      console.log ('ERRORE ', err);
  })
  }
  </code></pre>
  
  <p>so if I'm fetching a php url wich returns a json, when I console.log the data in I should see the html code echoed by the php and the json inside it, instead all I see is a string of numbers like 1137168 (I typedof it and it's a string...)</p>
  
  <p>** PHP CODE **</p>
  
  <pre><code>$selectNum = "SELECT num FROM table";
  $quer = mysqli_query($conn, $selectNum);  
  while($row = mysqli_fetch_array($quer, MYSQLI_ASSOC)){
      $arrayJSON = $row;
  }
  header('Content-Type: application/json');
  echo json_encode($arrayJSON, JSON_PRETTY_PRINT); 
  mysqli_close($conn); 
  </code></pre>
  
  <p>the php and the js are saparated files</p>