To create a structure similar to this:
params (Object) (defaults to: {}) —
Delete — required — (map)
Objects — required — (Array<map>)
Key — required — (String) Key name of the object to delete.
This is how it's being implemented:
var params = {
Bucket : data.bucket,
Delete: [{
Objects:[{ Key:""}] }]
};
for(i=0;i<data.keys.length;i++){
params.Delete[0].Objects[i].Key = data.keys[i];
}
An issue arises when setting the Key
with
params.Delete[0].Objects[i].Key = data.keys[i];
^
TypeError: Cannot assign value to 'Key' of undefined
Why is this error occurring?
It appears that there is only one instance of Key
within Objects
. I would like to include multiple keys inside Objects
in order to construct the object properly. How can this be achieved?