Guest User

Untitled

a guest
Jan 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. header("Content-Type: application/json; charset=UTF-8");
  2.  
  3. $stmt = $mysqli->prepare($sql);
  4. $stmt->execute();
  5. $result = $stmt->get_result();
  6. $response = $result->fetch_all(MYSQLI_ASSOC);
  7.  
  8. echo json_encode($response);
  9.  
  10. /*$fp = fopen('datakomp.json', 'w');
  11. fwrite($fp, json_encode($response));
  12. fclose($fp);*/
  13.  
  14. fetch('http://localhost:100/myreactappversi2/myapp2/public/data/tes2.php', {
  15. method: 'GET',
  16. headers:{
  17. 'Content-Type': ['application/json','charset=UTF-8'],
  18. },
  19. mode: "no-cors",
  20. cache: "no-cache",
  21. credentials: "include"
  22. })
  23. .then(response => response.json())
  24. .then(rowData => this.setState({rowData}))
  25. .catch(error => alert("Error : " + error))
Add Comment
Please, Sign In to add comment