Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
How do I parse an object coming back from AWS SES SDK in JavaScript?

I'm trying to use AWS SES getIdentityVerificationAttributes via code, and I'm having trouble parsing the object coming back.

I've made a mess out of the code below, but AWS says it is coming back as a map, so I tried doing a .get() and it threw an error that .get() is not a function. So I tried working with Object.entries but still I can't find a good way of returning the VerificationStatus of this object. I expected JSON.Parse(identityVerify) to work, but it doesn't (getting "ERROR SyntaxError: Unexpected token o in JSON at position 1").

const isEmailAWSVerified = async (Email) => {
    try {
        console.log('[isEmailAWSVerified] Email: ', Email);

   /*
    data = {
        VerificationAttributes: {
        "myEmail@example.com": {
        VerificationStatus: "Success", // Could be "Pending", "Failed"...
        VerificationToken: "EXAMPLE3VYb9EDI2nTOQRi/Tf6MI/6bD6THIGiP1MVY="
        }
      }
    }
   */

        let identityVerify= 
            await SES.getIdentityVerificationAttributes(
                {Identities: [`${Email}`]})
                .promise();
        
        console.log('[isEmailAWSVerified] - identityVerify', identityVerify);
        const parsedResponse = JSON.Parse(identityVerify);

        const ret = Object.entries(identityVerify.VerificationAttributes).map(([key, val]) => {
            let status = '';
            if (key === Email) {
                const tmp = JSON.Parse(val);
                console.log('[isEmailAWSVerified -- Inside Map] tmp: ', tmp);
                // status = Object.entries(val).map(([key, val]) => {
                //     return val;
                // });
                return status;
            }
            return '';
          })

        console.log('[isEmailAWSVerified] - ret', ret);
        
        return ret === 'Success' ? 1 : 0;
    } catch ( err) {
        console.log('[isEmailAWSVerified] - ERROR', err);
        return 0;
    }
}

I found a good example in PHP -- How can I translate that to JS?

try:
            response = self.ses_client.get_identity_verification_attributes(
                Identities=[identity])
            status = response['VerificationAttributes'].get(
                identity, {'VerificationStatus': 'NotFound'})['VerificationStatus']
            logger.info("Got status of %s for %s.", status, identity)
        except ClientError:
            logger.exception("Couldn't get status for %s.", identity)
            raise
        else:
            return status
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Actually, we don't need JSON.Parse, because is an object already. We can get verification status just by using const status = identityVerify.VerificationAttributes[${Email}].VerificationStatus;

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!