I am trying to fetch data from from php api here is the code of api
<?php 
if(!empty($_POST)){
        $array = ["name" => "vasu" ,"json" => "created at 2021"];
     print_r(json_encode($array));    
    }else{
        $array = ["error" => 22];
        print_r(json_encode($array));
    }
?>
Here is the code of my react nativ fetch method
 fetch(url,{
     method : "POST",
     body : JSON.stringify({
       name : "vasu"
     })
   })
    .then((response) => response.json())
    .then((json) => {
      console.log(json);
    })
    .catch((error) => {
      console.error(error);
    });
Output
{"error":22}
It means I can't get anything in $_POST How to fix this problem
 
    