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
.get(url)
.then((result) => {
// eslint-disable-next-line no-console
console.log('IN apiGet.THEN: ' + JSON.stringify({ success: true, result: result }))
if (result.status !== 200) {
// eslint-disable-next-line no-console
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)
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 }
})
.catch((error) => {

View File

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

View File

@ -6,6 +6,10 @@
* and open the template in the editor.
*/
if(isset($body['balance'])) {
$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) ?>