mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): fix for no-uncaught-json-parse warnings
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import { IDataObject, IHttpRequestOptions, NodeApiError } from 'n8n-workflow';
|
||||
import { IDataObject, IHttpRequestOptions, jsonParse, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function awsApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
@@ -18,7 +18,7 @@ export async function awsApiRequest(
|
||||
query: IDataObject = {},
|
||||
headers?: object,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('aws');
|
||||
|
||||
const requestOptions = {
|
||||
@@ -50,7 +50,7 @@ export async function awsApiRequestREST(
|
||||
query: IDataObject = {},
|
||||
headers?: object,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
): Promise<any> {
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, query, headers);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
@@ -70,23 +70,17 @@ export async function awsApiRequestAllItems(
|
||||
headers: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
|
||||
do {
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
service,
|
||||
method,
|
||||
path,
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
);
|
||||
responseData = await awsApiRequestREST.call(this, service, method, path, body, query, headers);
|
||||
if (responseData.NextToken) {
|
||||
const data = JSON.parse(body as string);
|
||||
// tslint:disable-next-line:no-any
|
||||
const data = jsonParse<any>(body as string, {
|
||||
errorMessage: 'Response body is not valid JSON',
|
||||
});
|
||||
data['NextToken'] = responseData.NextToken;
|
||||
}
|
||||
returnData.push.apply(returnData, get(responseData, propertyName));
|
||||
|
||||
Reference in New Issue
Block a user