Truncated console output in CloudCode

Hi Friends

How do I stop CC from truncating my console object?

I have a fairly large JSON object and when I console log it’s contents it gets truncated.

I tried console.log(JSON.stringify(obj)) and console.dir(obj), but the data is truncated in both cases

Hi @forumfred

When I ran into this “issue”, I resorted to emailing the object to myself as an attachment, to inspect the full object contents.

Here is a code snippet, in my case I wanted to inspect the contents of my report templateData object.

import sgMail from '@sendgrid/mail';
        var b = Buffer.from(JSON.stringify(templateData));
        var content = b.toString('base64');
const _email = {
        from: '', // Add the from email here
        to: '', // Add the to email here 
        subject: "Report Template Data",
        html: "- see attached ",
        attachments: [{
            'content': content,
            'type': "text/plain",
            'filename': "blob.txt",
            'disposition': 'attachment'
    await sgMail.send(_email);

Hope this helps you out until a better solution comes along.

1 Like

Nice! An alternative to mailing the file to yourself would be to just create and save the attachment / file in the JourneyApps DB.