Hopefully I am not crazy or this is something new about Javascript that I need to learn. I am writing an AngularJS app. I have the following script in Javascript;
$http({
url: urls.BASE_API + '/conversations/'+conversationid,
method: "Get"
}).then(function (response) {
if (angular.isDefined(response.data)) {
console.info ("The CONVERSATION!", response);
var Data = response.data;
Data.Messages = response.data.messages
delete Data.data;
options.success(Data);
}
}, function (response) { // optional
if (response.status = '404'){
options.failure({
message: "Conversation not found"
})
}
});
I have tested this many times. When delete Data.data; is removed the data is not available in the console.info() call. But console.info is called before delete. Why does this happen? What is the solution around this?