ReferenceError: path is not defined

Whenever I run my code I get this error

ReferenceError: path is not defined
    at https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:122:67
    at new Promise (<anonymous>)
    at https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:122:21
    at Array.forEach (<anonymous>)
    at loadFile (https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:29:9)
    at _.p.setup (https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:153:2)
    at _setup (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js:3:423972)
    at _start (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js:3:422871)

This is the code snippet I think might be causing the problem

case 'png':
case 'jpg':
case 'jpeg':
case 'gif':

	if (lib === 'p5') {
		// This code... V
		returnObj.p5 = new Promise((resolve, reject) => {p.loadImage(fileObj.path, resolve, reject)})
	}
	else if (lib === '3js') {
		returnObj.three = new THREE.ImageLoader(threeLoadingManager).load(fileObj.path, threeSuccessCallback, undifined, failureCallback)
	}

	break;

	// ...

fileObj is this: { path: 'BRUH.png', forLib: ['p5'] } for testing

Also, I’m running p5 in instance mode RN

This is the code that is running the function:

p.setup = () => {
	loadFile(filesToLoad[0], p).p5.then(console.log).catch(console.error)
	console.log(filesToLoad[0])
	// ...

My full code is currently hosted on repl.it

Some of your case statements are using just path instead of fileObj.path:


			// Font
			case 'otf':
			case 'ttf':

				if (lib === 'p5') {
					returnObj.p5 = new Promise((resolve, reject) => {p.loadFont(path, resolve, reject)})
				}
				break;
			
			// Raw Data (Bytes)
			default:

				if (lib === 'p5') {
					returnObj.p5 = new Promise((resolve, reject) => {p.loadBytes(path, resolve, reject)})
				}
				break;

Oh… That was dumb…
THANK YOU :slight_smile: