I'm completely new at Javascript and I'm trying to stringify an array of objects photos. When I try
console.log(photos)
it gives
Photos
[]
0: Object { name: "IMG_2910.jpg", path: "https://..." }
1: Object { name: "IMG_2911.jpg", path: "https://.." }
length: 2
<prototype>: Array []
When I try to stringify however with Json.stringify()
console.log("Photos again", JSON.stringify (photos))
I'm getting an empty array.
I understand from reading similar questions that stringify does not work on a usual array, have seen many examples though of using it on an array of objects and it works.
What could I be doing wrong here?
The photos are populated as follows:
uppy.on('complete', result => {
if (result.successful.length > 0) {
result.successful.forEach((element) => {
photos.push({
name: element.name,
path: element.uploadURL
});
});
};
});
And the logging is done as follows:
console.log("Photos", photos);
console.log("Photos again", JSON.stringify (photos));