I have an object with a Value
field. This field contains a very long string (base64). When using console.log
, the field seems to contain the string, however, when just printing out this one field, I just get an empty string:
I'm trying to send this object through a REST service, but it just sends the empty string instead of the correct value.
What is going on here? I've used these kind of strings before and it worked fine, but now it looks like I'm missing something important.
To make it clear, this gets the above output:
console.log(myObject);
This prints an empty string:
console.log(myObject.Value);
EDIT:
This is how the Value
is assigned:
for (var i = 0; i < vm.data.profileSettings.length; i++) {
(function (i) {
var setting = vm.data.settings.filter(function(setting) { return setting.Id == vm.data.profileSettings[i].Id });
if (setting[0].Type == 2 && vm.data.profileSettings[i].copiedValue && typeof(vm.data.profileSettings[i].copiedValue) == 'object') {
Upload.base64DataUrl(vm.data.profileSettings[i].copiedValue)
.then(function(response) {
var splitted = response.split(",");
vm.data.profileSettings[i].Value = splitted[1];
});
}
})(i);
}
profileDataService.saveProfileSettings(vm.data.selectedProfile.Id, vm.data.profileSettings)
.then(function(response) {
vm.success = true;
});