Reputation: 361
I am using slim withJson method to return header application json. But its returning text/html header. When i echo header of response object, it is application/json. So why it is returning text/html header in rest client or browser.
$app->get('/login', function($request,$response){
$data = [['name'=>'vaibhav']];
$newResponse = $response->withJson($data);
echo $newResponse->getHeaderLine('Content-Type');
return $newResponse;
});
Upvotes: 1
Views: 239
Reputation: 772
I think this is because you are doing echo $newResponse->getHeaderLine('Content-Type');
and then slim tries to send headers.
Try to comment echo string and check.
Upvotes: 1