try with application/json

This commit is contained in:
einhornimmond 2021-07-29 12:29:33 +02:00
parent b018ae894b
commit 32eeda69b2
3 changed files with 15 additions and 4 deletions

View File

@ -23,6 +23,9 @@ export const apiGet = async (url: string): Promise<any> => {
return axios return axios
.get(url) .get(url)
.then((result) => { .then((result) => {
// eslint-disable-next-line no-console
console.log('IN apiGet.THEN: ' + JSON.stringify({ success: true, result: result }))
if (result.status !== 200) { if (result.status !== 200) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('IN status: ' + 'HTTP Status Error ' + result.status) console.log('IN status: ' + 'HTTP Status Error ' + result.status)
@ -33,8 +36,6 @@ export const apiGet = async (url: string): Promise<any> => {
console.log('IN state: ' + result.data.state + ' message: ' + result.data.msg) console.log('IN state: ' + result.data.state + ' message: ' + result.data.msg)
throw new Error(result.data.msg) throw new Error(result.data.msg)
} }
// eslint-disable-next-line no-console
console.log('IN apiGet.THEN: ' + JSON.stringify({ success: true, result: result }))
return { success: true, result: result } return { success: true, result: result }
}) })
.catch((error) => { .catch((error) => {

View File

@ -271,6 +271,8 @@ class AppRequestsController extends AppController
public function getBalance($session_id = 0) public function getBalance($session_id = 0)
{ {
$this->viewBuilder()->setLayout('ajax'); $this->viewBuilder()->setLayout('ajax');
$this->response = $this->response->withType('application/json');
$login_result = $this->requestLogin($session_id, false); $login_result = $this->requestLogin($session_id, false);
if($login_result !== true) { if($login_result !== true) {
$this->set('body', $login_result); $this->set('body', $login_result);
@ -301,12 +303,16 @@ class AppRequestsController extends AppController
} }
$body['decay_date'] = $now; $body['decay_date'] = $now;
$this->addAdminError("AppRequests", "getBalance", $body, $user['id']);
$this->set('body', $body); $this->set('body', $body);
} }
public function listTransactions($page = 1, $count = 25, $orderDirection = 'ASC', $session_id = 0) public function listTransactions($page = 1, $count = 25, $orderDirection = 'ASC', $session_id = 0)
{ {
$this->viewBuilder()->setLayout('ajax'); $this->viewBuilder()->setLayout('ajax');
$this->response = $this->response->withType('application/json');
$startTime = microtime(true); $startTime = microtime(true);
$login_result = $this->requestLogin($session_id, false); $login_result = $this->requestLogin($session_id, false);

View File

@ -6,6 +6,10 @@
* and open the template in the editor. * and open the template in the editor.
*/ */
$body['balance'] = $this->element('centToFloat', ['cent' => $body['balance'], 'precision' => 4]); if(isset($body['balance'])) {
$body['decay'] = $this->element('centToFloat', ['cent' => $body['decay'], 'precision' => 4]); $body['balance'] = $this->element('centToFloat', ['cent' => $body['balance'], 'precision' => 4]);
}
if(isset($body['decay'])) {
$body['decay'] = $this->element('centToFloat', ['cent' => $body['decay'], 'precision' => 4]);
}
?><?= json_encode($body) ?> ?><?= json_encode($body) ?>