I am upgrading my site. I upgraded to AngularJS v1.7.6 and JQuery v1.12.1 I get this error message in my console log.
TypeError: Cannot read property 'CustomerId' of undefined
All I did was change .success to .then as .success was depreciated.
Here is the code where I made the change. So I believe data[0] is null so there is no property CustomerId. This function would work with my older version of jquery and angular with the method of .success instead of .then
I am not sure what to do to fix this...(going in circles here)
$scope.sessionDetails = function () {
urlService.dataProvider(sessionMethod, "POST", '').then(function (data) {
$scope.sesCustomerId = data[0].CustomerId;
$scope.sesToken = data[0].Token;
$scope.sesCustomerName = data[0].CustomerName;
$scope.sesUserIsMember = data[0].IsMember;
$scope.userEmail = data[0].Email;
var indexFavUrl = wLArray.indexOf("Favourites");
if (wLArray[indexFavUrl] == "Favourites") {
if ($scope.sesCustomerId != '') {
//Getting User Favourite Items with customer Id
$scope.GetFavouriteItems($scope.sesCustomerId);
}
}
/* To Open Popup after login */
if (sessionStorage.getItem("CustomPro") == "fromCompse") {
if (!sessionStorage.getItem("UMBID")) {
var cprt = window.location.search.split("=")[1];
var isprodmemonly = window.location.search.split("=")[2];
}
else {
var cprt = sessionStorage.getItem("UMBID");
var isprodmemonly = sessionStorage.getItem("UMBID_IsMem") == "true" ? true : false;
}
show();
if ($scope.sesUserIsMember != "1" && isprodmemonly) {
jAlert('This Product is only for members.');
sessionStorage.removeItem("CustomPro");
return false
} else {
$scope.ProductCompose(cprt, '', cprt, isprodmemonly);
}
}
});
}
$scope.sessionDetails();