I get a JSON Object as input in my function (pImageArray). I loop over this object, read data from a storage and get a new JSON object back (see image attached). Now and want to map one field "href" in a new object (data). I get the error "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')"
I can not solve the issue. Any ideas? THX.
my code:
getFileForView: function (pImageArray) {
const storage = new Storage(client);
pImageArray.forEach(function (element) {
const result = storage.getFileView(bucketID, element.image_ID);
console.log("--- image for view in loop : ", result.href); // Success
console.log("--- image result : ", result); // Success
const data = result.map(value => ({
href: value.href
}));
console.log("--- data : ", data);
});
getFileForView: function (pImageArray) {
const storage = new Storage(client);
var jsonData = [];
var newJSONData = [];
pImageArray.forEach(function (element) {
const result = storage.getFileView(bucketID, element.image_ID);
console.log("--- image for view in loop : ", result.href); // Success
console.log("--- image result : ", JSON.stringify(result)); // Success
jsonData["href"] = result.href;
newJSONData.push(jsonData);
console.log("--- data : ", newJSONData);
});