mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
check response for errors
This commit is contained in:
parent
a0af1d9a06
commit
7039173b06
|
@ -37,7 +37,22 @@ export async function mondayComApiRequest(
|
||||||
if (authenticationMethod === 'oAuth2') {
|
if (authenticationMethod === 'oAuth2') {
|
||||||
credentialType = 'mondayComOAuth2Api';
|
credentialType = 'mondayComOAuth2Api';
|
||||||
}
|
}
|
||||||
return await this.helpers.requestWithAuthentication.call(this, credentialType, options);
|
|
||||||
|
const responseData = await this.helpers.requestWithAuthentication.call(
|
||||||
|
this,
|
||||||
|
credentialType,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
responseData.hasOwnProperty('error_message') ||
|
||||||
|
responseData.hasOwnProperty('error_code') ||
|
||||||
|
responseData.hasOwnProperty('errors')
|
||||||
|
) {
|
||||||
|
throw new NodeApiError(this.getNode(), responseData as JsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||||
}
|
}
|
||||||
|
@ -88,6 +103,14 @@ export async function mondayComApiPaginatedRequest(
|
||||||
})) as IDataObject
|
})) as IDataObject
|
||||||
).data as { next_items_page: { cursor: string; items: IDataObject[] } };
|
).data as { next_items_page: { cursor: string; items: IDataObject[] } };
|
||||||
|
|
||||||
|
if (
|
||||||
|
responseData.hasOwnProperty('error_message') ||
|
||||||
|
responseData.hasOwnProperty('error_code') ||
|
||||||
|
responseData.hasOwnProperty('errors')
|
||||||
|
) {
|
||||||
|
throw new NodeApiError(this.getNode(), responseData as JsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
if (responseData && responseData.next_items_page) {
|
if (responseData && responseData.next_items_page) {
|
||||||
returnData.push.apply(returnData, responseData.next_items_page.items);
|
returnData.push.apply(returnData, responseData.next_items_page.items);
|
||||||
cursor = responseData.next_items_page.cursor;
|
cursor = responseData.next_items_page.cursor;
|
||||||
|
|
Loading…
Reference in a new issue