I have a problem with a form that has autofill, when I select the record that contains the information, the data is not loaded in the related fields of the form, apparently it is because there is an error in the client side event when a function cannot be executed of the api that updates the patient's age, I am using the administrator user so I don't understand why it says that access to the function is not authorized.
PHPmaker 2021
The Startup Script calling api
$.ajax({
url: 'api/edadPaciente/' + $paciente,
type: 'GET',
contentType:'json',
dataType: 'json',
async:false,
success: function (data) {
console.log(data);
typeof(data);
$edad = data;
console.log($edad);
$('#x_edad').val($edad);
},
error: function (xhr, textStatus, errorThrown) {
console.log('a' + textStatus);
}
});
The function is in Global-> Api_Action
//Consulta edad del paciente
$app->get('/edadPaciente/{paciente}', function ($request, $response, $args) {
// Get input values
$paciente = $args["paciente"];
if ($paciente !== null) {
$mSql = "";
$mSql = "SELECT fnc_paciente_edad('" . AdjustSql($paciente) . "') AS edad; " ;
$response = $response->withJson(ExecuteScalar($mSql)); // Output field value as string
}
return $response; // Return Psr\Http\Message\ResponseInterface object
});
This is the error in client side
jquery-3.6.0.min.js:2
GET http://localhost:8089/hrmedic/api/edadPaciente/ 401 (Unauthorized)