$http.post request returns data null

The status is fine but then the data return is null.
What i want to do is that the localstorage value which i put into a variable “userid” will be used in my php code.
Here is my code.

var _this = this;
var link = ‘’;
var userid = localStorage.getItem(‘loginDetails’);

  $http.post(link, {userid}).then(function(res){
    _this.response = res.data;

this is my php code

<?php header("Access-Control-Allow-Origin: *"); require_once('connection.php'); $post_data = file_get_contents('php://input'); $request = json_decode($post_data); $userid = $request->userid; $subject_sql ="SELECT SubjectName FROM subjects WHERE userid = '" .$userid. "' "; $result = $con->query($subject_sql); $re=$result->fetch_assoc(); echo json_encode($re); ?>