Small improvements to Hubspot-Node

This commit is contained in:
Jan Oberhauser 2020-04-20 09:22:31 +02:00
parent 1484427a59
commit 6cc1c771ea
2 changed files with 8 additions and 2 deletions

View file

@ -141,7 +141,7 @@ export const companyFields = [
description: 'The domain name of the company or organization' description: 'The domain name of the company or organization'
}, },
{ {
displayName: 'Company Owmer', displayName: 'Company Owner',
name: 'companyOwner', name: 'companyOwner',
type: 'options', type: 'options',
typeOptions: { typeOptions: {

View file

@ -33,7 +33,13 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
} catch (error) { } catch (error) {
if (error.response && error.response.body && error.response.body.errors) { if (error.response && error.response.body && error.response.body.errors) {
// Try to return the error prettier // Try to return the error prettier
const errorMessages = error.response.body.errors; let errorMessages = error.response.body.errors;
if (errorMessages[0].message) {
// @ts-ignore
errorMessages = errorMessages.map(errorItem => errorItem.message);
}
throw new Error(`Hubspot error response [${error.statusCode}]: ${errorMessages.join('|')}`); throw new Error(`Hubspot error response [${error.statusCode}]: ${errorMessages.join('|')}`);
} }