So I am connecting to call of duty api (using Laravel in the back), and getting all the info I get back in a variable ($data), then I want to return just part of it something like:
return ($data->data->lifetime)
but I get the "Trying to get property 'data' of non-object" message all the time. If I just return data, and in the front I acces to the property like this:
console.log(data.data.lifetime)
it throws me what I wants, but the thing is that I need to deal with it in the back, so which one would it be the right way to access just to the properties I want? (I have also tried using json_decode in the return)
this is the json I am getting, I want to acces to lifetime which is inside data
{status: "success", data: {…}}
status: "success"
data:
title: "mw"
platform: "battle"
username: "fire#2749"
type: "mp"
level: 88
maxLevel: 0
levelXpRemainder: 3000
levelXpGained: 7000
prestige: 0
prestigeId: 0
maxPrestige: 0
totalXp: 960000
paragonRank: 0
paragonId: 0
s: 5
lifetime:
all: {properties: {…}}
mode: {dom: {…}, war: {…}, hq: {…}, hc_dom: {…}, hc_conf: {…}, …}
map: {}
itemData: {weapon_sniper: {…}, tacticals: {…}, lethals: {…}, weapon_lmg: {…}, weapon_launcher: {…}, …}
scorestreakData: {lethalScorestreakData: {…}, supportScorestreakData: {…}}
accoladeData: {properties: {…}}
__proto__: Object
weekly: {all: {…}, mode: {…}, map: {…}}
engagement: null
__proto__: Object
__proto__: Object
json_decode($data, true);? This will return associative arrays which is what you want.