How to delete pointed object using Cloud Code?

Disclaimer: I am new to Parse and not a javascript dev, so I’m winging much of this. Also, I’m using Back4App as the host running Parse 3.9.0 (I know, old and security risky)

I have a ParseObject Profile, that has pointers to another ParseObject Details, and a ParseFile Image. When I delete the Profile, I want to delete the Details and Image as well. I figured the best way to do this is via Cloud Code. Here is what I have:

Parse.Cloud.beforeDelete("Profile", (request) => 
{    
    var profile = request.object;
    if (profile.has("details"))
    {
        var details = profile.get("details");
        details.destroy();    	
        console.log("DID: delete details");	
	}
	
	if (profile.has("image"))	
	{
        var image = profile.get("image");
		  console.log("TODO: delete image");
		// image.destroy();
	}
});

One, (which I commented out) is that “image.destroy is not a function”. I thought using Cloud Code was suppose to be the way one could destroy images? What is the proper way to do this? I’d rather not leave orphan’d file laying about.

Two, the cloud process completes without an error back to the client (Unity) and deletes the profile, but the server logs say differently:

[2020-08-03T19:58:37.230Z]
DID: delete details

[2020-08-03T19:58:37.242Z]
(node:18) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)

[2020-08-03T19:58:37.242Z]
(node:18) UnhandledPromiseRejectionWarning: Error: Object not found.
at /usr/src/app/node_modules/parse/lib/node/RESTController.js:367:19
at processTicksAndRejections (internal/process/task_queues.js:89:5)

What did I do wrong? Do I need to fetch the details object before deleting it?

Any suggestions would be appreciated?

After various searches and trial and error, I found I was missing session info since my ACL only allows the owner/user to delete.

if (profile.has("details"))
{
    var details = profile.get("details");
    details.destroy({ sessionToken: userToken }).then(_ => 
    {
        // console.log("DID delete details");    
    }, (error) => {
        console.log("FAILED to delete details");    
	}); // )        
}