IPFS-BULK-UPLOAD project 'toString' error

na … still issues … same error code… its something on my end … i changed
for (let i = 0; i < 100; i++) { to for (let i = 1; i < 1; i++) { and it prints one pic… i have 50 in the file … so idk … when i keep the orignal code it comes with the toString error…

try i < 10 instead if i < 1

back with the toString error

with a smaller number then, like 4?

yea i printed 3 more… hmmmm… whats up with this lol

let fs = require(“fs”);

let axios = require(“axios”);

let ipfsArray = [];

let promises = [];

for (let i = 0; i < 5; i++) {

let paddedHex = ("0000000000000000000000000000000000000000000000000000000000000000" + i.toString(16)).substr("-64");



promises.push(new Promise( (res, rej) => {

    fs.readFile(`${__dirname}/export/${paddedHex}.jpg`, (err, data) => {

        if(err) rej();

        ipfsArray.push({

            path: `images/${paddedHex}.jpg`,

            content: data.toString("base64")

        })

        res();

    })

}))

}

Promise.all(promises).then( () => {

axios.post("https://deep-index.moralis.io/api/v2/ipfs/uploadFolder",

    ipfsArray,

    {

        headers: {

            "X-API-KEY": 'szaiOQef4xaAJhvjqrVuRSwqs28lvbB1nPX7sZUMKghL0XE5UaxTnO5soJIba1J9',

            "Content-Type": "application/json",

            "accept": "application/json"

        }

    }

).then( (res) => {

    console.log(res.data);

})

.catch ( (error) => {

    console.log(error)

})

})

content: data.toString(“base64”)
^

TypeError: Cannot read properties of undefined (reading ‘toString’)
at ReadFileContext.callback (D:\NFT MARKETPLACE\2 january ipfs\images.js:15:31)
at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:314:13)

Node.js v17.3.1

It means that data variable is undefined