Reputation: 1654
Currently my code is like this:
$newResponse = $response
->withStatus(200, 'Logged in!')
->withHeader('jwt',$jwt);
If I try to add ->withBody(), it requires some kind of Streaminterface object, I would just like to add the Jwt token to the body since in my ReactJS the request says it is type cors and apparently I can't access the JWT token because the http type is cors.
$newResponse = $response
->withStatus(200, 'Logged in!')
->withHeader('jwt',$jwt)
->withBody($jwt);
Here's the image from chrome inspect
Upvotes: 1
Views: 1030
Reputation: 5262
withBody()
method will return new instance of ResponseInterface
with its body replaced with instance that you pass from its parameter. If your concern is only to write something to body then you can call getBody()
and write your data there.
$newResponse = $response
->withStatus(200, 'Logged in!')
->withHeader('jwt',$jwt);
$newResponse->getBody()->write($jwt);
Upvotes: 1