mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Improvements to Google Tasks node
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function googleApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
@@ -27,6 +31,7 @@ export async function googleApiRequest(
|
||||
uri: uri || `https://www.googleapis.com${resource}`,
|
||||
json: true
|
||||
};
|
||||
|
||||
try {
|
||||
if (Object.keys(headers).length !== 0) {
|
||||
options.headers = Object.assign({}, options.headers, headers);
|
||||
@@ -41,10 +46,14 @@ export async function googleApiRequest(
|
||||
options
|
||||
);
|
||||
} catch (error) {
|
||||
if (error.response && error.response.body && error.response.body.message) {
|
||||
if (error.response && error.response.body && error.response.body.error) {
|
||||
|
||||
let errors = error.response.body.error.errors;
|
||||
|
||||
errors = errors.map((e: IDataObject) => e.message);
|
||||
// Try to return the error prettier
|
||||
throw new Error(
|
||||
`Google Tasks error response [${error.statusCode}]: ${error.response.body.message}`
|
||||
`Google Tasks error response [${error.statusCode}]: ${errors.join('|')}`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user