I'm working with angular and laravel,I have this json in my request, but for some reason I cannot access to the data inside the key called "llave_criptografica" , this is the complete json
{username: "eeded", contrasena: null, llave_criptografica: {…}, clave_criptografica: null}
the data inside "llave_criptografica" is this
{filename: "011503046233.p12", filetype: "application/x-pkcs12", value: "MIIaPAIBAzCCGfYG-base-64-encode"}
as you can see, I just have encoded and send a key with base64, but when I try to access to it, I get this error
return $request->llave_criptografica->filename;
Trying to get property of non-object
if I try to access as an array this is the error
return $request->llave_criptografica["filename"];
Unexpected number in JSON at position 1 at JSON.parse
this is the function where I store the file data
onFileChange(event) {
let reader = new FileReader();
if(event.target.files && event.target.files.length > 0) {
let file = event.target.files[0];
reader.readAsDataURL(file);
reader.onload = () => {
this.formCertificado.get('llave_criptografica').setValue({
filename: file.name,
filetype: file.type,
value: reader.result.split(',')[1]
})
}
}
}
When I do a log, this is the content of the key
array ( 'username' => 'eded', 'contrasena' => NULL, 'llave_criptografica' => array ( 'filename' => '011503046233.p12', 'filetype' => 'application/x-pkcs12', 'value' => 'MIIaP-base-64', ), 'clave_criptografica' => NULL, )