I'm making an api call to gather data on a customer, and then saving specific key:value pairs into a global variable.
What's confusing me is that when I console log the object I'm getting back from the api, I'm able to see said data. However, when this data is saved to this global variable (maildata), all key:value pairs are blank.
Here is what my function looks like. This is a vuejs/javascript project.
'''
getAllData(obj) {
let params = new URLSearchParams();
let thisvue = this;
let url = this.$store.state.url;
let newObj = JSON.stringify(obj);
params.append('ty', 'allpdf');
params.append('prikey', newObj);
axios({
method: "post",
url: url,
data: params
})
.then((response) => {
console.log(response.data); //I am able to see object data with this
thisvue.maildata=response.data; //Saved response.data into maildata global variable
console.log(thisvue.maildata); //Unable to see data when saved to this variable
})
.then(() => {
thisvue.maildata.pay=JSON.parse(thisvue.maildata.pay);
thisvue.maildata.deductions=JSON.parse(thisvue.maildata.deductions);
thisvue.maildata.exemptions=JSON.parse(thisvue.maildata.exemptions);
thisvue.maildata.explanations=JSON.parse(thisvue.maildata.explanations);
})
}'''