Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda