code: public function execute()
      {
          $result = $this->resultJsonFactory->create();
          try {
              $customer = $this->api->getCustomerInfo();
  
              if (!$customer) {
                  return $result->setData(['status' => false]);
              }
  
              return $result->setData([
                  'status'    => true,
                  'customer'  => $customer
              ]);
          } catch (\Exception $e) {
              return $result->setData([
                  'status'    => false,
                  'msg'       => $e->getMessage()
              ]);
          }
      }
docs: Checking service details
  
  @return \Magento\Framework\Controller\Result\Json