I am making a request get with axios the problem is that when reading the property of the json I get undefined, I'm using php slim on the server as api, on the client side is a mobile app with nativescript-vue I leave the code to see what the error is
slim php code
$app->get('/getToken', function ($request, $response, $args) {
// CSRF token name and value
$nameKey = $this->csrf->getTokenNameKey();
$valueKey = $this->csrf->getTokenValueKey();
$name = $request->getAttribute($nameKey);
$value = $request->getAttribute($valueKey);
$arreglo=array("namekey"=>$name ,"valuekey"=>$value);
$response->write(json_encode($arreglo,JSON_UNESCAPED_SLASHES));
});
the code in the client
function GetToken(){
console.log("entramos en getToken");
axios.get("http://tallerinternet.esy.es/getToken").then(respuesta=>{
console.log(respuesta.data);
console.log(respuesta.data.namekey);
}).catch(function (error) {
// handle error
console.log("error " + error);
});
}
when doing the console.log (answer.data) it shows me the structure of the json
{
"namekey":"csrf5b9975d057d61",
"valuekey":"63b5e0e720bffd5a8ccad0257d61ff62"
}
but when I try to print the property with console.log (answer.data.namekey) it gives me undefined,
I may be missing something when making the request with axios
in this link you will find what has an answer that comes from the server link but if I occupy the http module that comes by default in the data the slash does not appear.