How to make proper post request while creating restful api

<?php $app->post('/bulk',function(Request $request,Response $response ){ $data = $request->getParsedBody(); }); ?>

and now whenever i’m trying to send data through ajax error response comes back and also in my /bulk it says method not allowed must be one of post and status code in the console is 405