I have created a list of signed URLS from a table of keys (this triggers row by row getSignedURL which returns the signed URL from my google bucket)
getSignedurls JS
const promises = formatDataAsArray(table.data).map(row => {
return getSignedURL.trigger({
additionalScope: {
name: row.key
},
});
});
return Promise.all(promises);
I want to be able to refer to this array not by index getsignedurls.data[0], but by the original keys, getsignedurls.data[key_name] and return the signed URL. How would I augment this script?
I have another helper which maps a bunch of keys to a bunch of values so I think all that is needed is a combination of what is below with what is above:
let dictionary = Object.assign({}, ...data.map((x) => ({[x['gcs_name']]: x['signedUrl']})));
return dictionary
Something like this but it still isn't right:
let dictionary = Object.assign({}, ...data.map((x) => ({[x['gcs_name']]: getSignedProfile.trigger({
additionalScope: {
name: x['gcs_name']
},
});})));
return dictionary
I think actually this is a work around:
let result = Object.assign.apply({}, formatDataAsArray(table.data).map( (v, i) => ( {[v.gcs_name]: signedUrlTable.data[i].signedUrl} ) ) );
return result