I’m trying to get a list of products via user ID through an API.
I can usually get the product list via postman.
Here are screenshots of the postman.
In my code I try to get the list like this:
public function index()
{
$session = $this->getRequest()->getSession();
$http = new Client(['headers' => ['Authorization' => 'Bearer ' . $session->read('Config.TOKEN')]]);
$response = $http->get('http://localhost:8889/api/...',
[
'user_id' => $session->read('Config.ID'),
]);
var_dump($response);
if ($response->isOk()) {
$json = $response->getJSON();
$this->set('json', $json["data"]);
$this->set(compact('json'));
}
}
This is the return I get on the frontend using cakephp 4. Can you help me parse this?