I have cloudflare worker using the AWS sdk bucket for CRUD operations on a R2 bucket. I'm trying to

I have cloudflare worker using the AWS sdk bucket for CRUD operations on a R2 bucket. I'm trying to implement the Delete part and I'm running into a problem with the @aws-sdk/client-s3 DeleteObjectCommand .
    try {
        const url = new URL(request.url);
        const params = url.searchParams;
        const key = params.get('key');

        console.log('key', key);
        const data = await S3.send(new DeleteObjectCommand({
            Bucket: 'fakeBucket',
            Key: key
        }));

        return new Response(JSON.stringify({
            msg: 'I mean, something happened!',
            data: data
        }), {
            status: 200,
            headers: headers
        });

    } catch (err) {
        return new Response(JSON.stringify(
            { 
                msg: 'Error', 
                error: err 
            }), 
            { 
                status: 500, 
                headers: headers 
            });
    }

it still deletes the object but my worker returns an error
{
    "msg": "Error",
    "error": {
        "$metadata": {
            "attempts": 1,
            "totalRetryDelay": 0
        }
    }
}

I know DeleteObjectCommand is technically not supported yet but are there any other ways to do this from workers?
Was this page helpful?