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

@@ -33,7 +33,13 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
} catch (error) {
if (error.response && error.response.body && error.response.body.errors) {
// 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('|')}`);
}