Wp Rest Api Custom End point POST request
<p>Im trying to post some data to custom api endpoint that i created,</p>

<p>This is what my wordpress custom endpoint code.</p>

<pre><code>register_rest_route( 'api/v1', '/cities', array(
    'methods' =&gt; 'POST',
    'callback' =&gt; 'create_city_from_data'
));
</code></pre>

<p>And for testing I am trying to return the request like this</p>

<pre><code>function create_city_from_data($req) {
  return ['req' =&gt; $req];
}
</code></pre>

<p>but always i receive empty object as response, whatever i send in payload i didn't receive anything.</p>

<p>My payload is something like this</p>

<pre><code>{ name: 'Hello', population: 565656 }
</code></pre>

<p>This is what is received from the request</p>

<pre><code>{"req":{}}
</code></pre>