getBody()->write(json_encode($data)); return $response->withHeader('Content-Type', 'application/json'); } }