I have an array who's called files_url
. I fill it like this:
var files_url = new Array(filesnb);
var files_name = new Array(filesnb);
for (var i = 0, k = 0; i < filesnb; i++) {
files_name[i] = selectedFile[i].name;
const uploadTask = storageRef.child(`${selectedFile[i].name}`).put(selectedFile[i]);
uploadTask.on('state_changed', (snapshot) => {
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
}, (error) => {
console.log(error);
}, () => {
uploadTask
.then(snapshot => snapshot.ref.getDownloadURL())
.then((url) => {
//Here is the part where i fill my array "files_url"
for (var len = 0; len < i; len++) {
if (check_right_url(files_name[len], url) === 0) {
files_url[len] = url;
console.log(i);
console.log(len);
break;
}
}
})
});
}
When I console.log(files_url)
I can see the right informations on my array, but when I try to do console.log(files_url[0])
, it show me undefined
. Why? How can I retrieve the content of the array?
Here is some screen:
When I do console.log(files_url)
:
When I do console.log(files_url[0])
: