Having trouble accessing the elements of the file array
const p_page = postP.new_pages;
const p_page_o = postP.new_pages_order;
const p_page_o_len = p_page_o.length;
if (p_page_o_len > 0) {
for (let i = 0; i < p_page_o_len; i++) {
console.log(p_page); //Array with files inside it displayed
console.log(p_page[0]); //displays undefined
console.log(p_page[i]); //also displays undefined
formData.append("pages[]", p_page[i]);
formData.append("pages_order[]", p_page_o[i]);
}
}
When attempting to log them:
https://i.sstatic.net/MgSAA.png
Edit: Essentially, I am adding image files to an array and then combining them in a FormData before sending them to the backend using a loop. While I can see the p_page logged in the console, I am unable to access any child element in the array as they are all showing as undefined. Apologies for any confusion in my explanation.