TypeError: Cannot read properties of undefined (reading 'push')
at kmeans (/Users/ajtadeo/GitHub/Spotipi/kmeans.js:128:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async fetchColors (/Users/ajtadeo/GitHub/Spotipi/app.js:70:22)
at async Request._callback (/Users/ajtadeo/GitHub/Spotipi/app.js:101:30)
// kmeans.js
async function kmeans(albumURL) {
// ...
while (true) {
// for each point, determine euclidean distance to each centroid and add it to the closest centroid cluster
iters++
var clusters = [[], [], [], [], []]
for (var i = 0; i < pixelDataLAB.length; i++) {
var distances = []
for (var j = 0; j < 5; j++) {
distances.push(deltaE(pixelDataLAB[i], centroids[j]))
}
var minIndex = distances.indexOf(Math.min(...distances))
clusters[minIndex].push(pixelDataLAB[i]) // ERROR HERE
}
// ...
(node:3756) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [Connection]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
This might be a result of the postgres db code since that was the latest change.