MadKudu / node-hubspot

Node wrapper for the HubSpot API
MIT License
192 stars 157 forks source link

decode error object #149

Closed adirzoari closed 5 years ago

adirzoari commented 5 years ago

I'm trying to decode error object message

     async createContact(data) {

        try {
            let contact = await this.hubspot.contacts.create(data)
            return contact;
        }catch(e){
            debug('error object',e)
            throw new Error(e)
        }

}

I get this print in terminal Error: StatusCodeError: 409 - {"status":"error","message":"Contact already exists","correlationId":"3c5db087-36d0-415c-94ef-039de03b848a","identityProfile":{"vid":2751,"identity":[{"value":"yamelzoari@gmail.com","type":"EMAIL","timestamp":1545572760708,"isPrimary":true},{"value":"a389c82e-60b3-4ef0-9c7c-4f19e432c0d3","type":"LEAD_GUID","timestamp":1545572760719}],"linkedVid":[],"isContact":true,"savedAtTimestamp":1545572760723},"error":"CONTACT_EXISTS","requestId":"71e6085bfec2c5d13046f6b344beed0e"} but when I can't print the error message, it's not object.

pcothenet commented 5 years ago

@adirzoari I don't fully understand your problem, what do you mean by "when I can't print the error message, it's not object."?

vkhomiv-hubspot commented 5 years ago

Hi @adirzoari, is this issue still relevant? I'm going to close it if there no additional information.