mysql - GET request from PHP to React

one text

Solution:

Return data in json format from php file

<?php
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET,PUT,POST,DELETE,PATCH,OPTIONS');

    $con = mysqli_connect("localhost", "root", "", "demo");

    $select_user = "SELECT * FROM users";
    
    $result = mysqli_query($con, $sql);
    
    $data = array()
    while($row = mysqli_fetch_array($result)) {
       array_push($data,$row['name']."".$row['email']); // push data to empty array
    }

    echo json_encode($data);
 ?>

Source