3 Fixed Indentation
source | link

Just try with

return $this->resultJsonFactory->create()->setData(['Test-Message' => $message])

instead of:

$result = $this->resultJsonFactory->create();

    $result->setData(['Test-Message' => $message]);
    return $result;  

Note: on __construct function, You need to add jsonFactory class

protected $resultJsonFactory;  

public function __construct(
       .....
 
    \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
   \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
...
    ) {
       ....
        $this->resultJsonFactory = $resultJsonFactory;
......
    ...
    parent::__construct(
          ....
        );
    }

Just try with

return $this->resultJsonFactory->create()->setData(['Test-Message' => $message])

instead of:

$result = $this->resultJsonFactory->create();

    $result->setData(['Test-Message' => $message]);
    return $result;  

Note: on __construct function,You need to add jsonFactory class

protected $resultJsonFactory; 
public function __construct(
       .....
 
        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
...
    ) {
       ....
        $this->resultJsonFactory = $resultJsonFactory;
......
        parent::__construct(
          ....
        );
    }

Just try with

return $this->resultJsonFactory->create()->setData(['Test-Message' => $message])

instead of:

$result = $this->resultJsonFactory->create();

$result->setData(['Test-Message' => $message]);
return $result;  

Note: on __construct function, You need to add jsonFactory class

protected $resultJsonFactory; 

public function __construct(
    ...
    \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
    ...
) {
    ...
    $this->resultJsonFactory = $resultJsonFactory;
    ...
    parent::__construct(
        ...
    );
}
2 added 7 characters in body
source | link

Just try withJust try with

$this->resultJsonFactory->create()->setData(['Test-Message' => $message])

return $this->resultJsonFactory->create()->setData(['Test-Message' => $message])

instead of:instead of:

$result = $this->resultJsonFactory->create();

    $result->setData(['Test-Message' => $message]);
    return $result;  

Note: on __construct function,You need to use :Note: on __construct function,You need to add jsonFactory class

protected $resultJsonFactory; 
public function __construct(
       .....

        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
...
    ) {
       ....
        $this->resultJsonFactory = $resultJsonFactory;
......
        parent::__construct(
          ....
        );
    }

Just try with

$this->resultJsonFactory->create()->setData(['Test-Message' => $message])

instead of:

$result = $this->resultJsonFactory->create();

    $result->setData(['Test-Message' => $message]);
    return $result;  

Note: on __construct function,You need to use :

protected $resultJsonFactory; 
public function __construct(
       .....

        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
...
    ) {
       ....
        $this->resultJsonFactory = $resultJsonFactory;
......
        parent::__construct(
          ....
        );
    }

Just try with

return $this->resultJsonFactory->create()->setData(['Test-Message' => $message])

instead of:

$result = $this->resultJsonFactory->create();

    $result->setData(['Test-Message' => $message]);
    return $result;  

Note: on __construct function,You need to add jsonFactory class

protected $resultJsonFactory; 
public function __construct(
       .....

        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
...
    ) {
       ....
        $this->resultJsonFactory = $resultJsonFactory;
......
        parent::__construct(
          ....
        );
    }
1
source | link

Just try with

$this->resultJsonFactory->create()->setData(['Test-Message' => $message])

instead of:

$result = $this->resultJsonFactory->create();

    $result->setData(['Test-Message' => $message]);
    return $result;  

Note: on __construct function,You need to use :

protected $resultJsonFactory; 
public function __construct(
       .....

        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
...
    ) {
       ....
        $this->resultJsonFactory = $resultJsonFactory;
......
        parent::__construct(
          ....
        );
    }