I have a function that is returning a null value instead of waiting for the inner promise to resolve before returning.
I've tried using async/await, but wasn't successful. The getTargets function needs to return upload_url, not a promise.
function getTargets (currentChunk) {
let chunkArray = [];
// split chunk strings into key value pairs, then add them to an array
for(let parameter of currentChunk) {
let keyValue = parameter.split('=');
chunkArray[keyValue[0]] = keyValue[1];
}
for(let file of myFiles) {
if (file.name === chunkArray['resumableFilename']) {
myService.getUploadUrl(file.id, chunkArray['resumableChunkNumber'], file.upload_id).then((response) => {
console.log(response.upload_url);
return response.upload_url;
});
}
}
}