1-
1+ /* eslint-disable n8n-nodes-base/node-param-options-type-unsorted-items */
22import {
33 IDataObject ,
44 IExecuteFunctions ,
55 IHttpRequestMethods ,
66 INodeExecutionData ,
7+ INodeProperties ,
78 INodeType ,
89 INodeTypeDescription ,
910} from 'n8n-workflow' ;
@@ -168,7 +169,7 @@ export class HasData implements INodeType {
168169
169170 async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
170171 const items = this . getInputData ( ) ;
171- const returnData : IDataObject [ ] = [ ] ;
172+ const returnData : INodeExecutionData [ ] = [ ] ;
172173 const resource = this . getNodeParameter ( 'resource' , 0 ) as string ;
173174 const operation = this . getNodeParameter ( 'operation' , 0 ) as string ;
174175
@@ -182,7 +183,11 @@ export class HasData implements INodeType {
182183 // Endpoint Logic
183184 const opKebab = operation . replace ( / _ / g, '-' ) ;
184185 if ( resource === 'google_serp' || resource === 'google_images' ) {
185- endpoint = `/scrape/google/${ opKebab } ` ;
186+ if ( operation === 'serp_light' ) {
187+ endpoint = '/scrape/google-light/serp' ;
188+ } else {
189+ endpoint = `/scrape/google/${ opKebab } ` ;
190+ }
186191 } else if ( resource === 'google_travel' ) {
187192 endpoint = `/scrape/google/${ opKebab } ` ;
188193 } else if ( resource === 'google_maps' ) {
@@ -199,7 +204,7 @@ export class HasData implements INodeType {
199204
200205 // Parameter Handling
201206 // We need to fetch parameters dynamically based on the resource fields
202- let relevantFields : any [ ] = [ ] ;
207+ let relevantFields : INodeProperties [ ] = [ ] ;
203208 if ( resource === 'airbnb' ) relevantFields = airbnbFields ;
204209 else if ( resource === 'amazon' ) relevantFields = amazonFields ;
205210 else if ( resource === 'bing' ) relevantFields = bingFields ;
@@ -230,7 +235,7 @@ export class HasData implements INodeType {
230235 const originalName = fieldName . replace ( / _ _ o p t _ _ / g, '[' ) . replace ( / _ _ c l t _ _ / g, ']' ) ;
231236 qs [ originalName ] = value ;
232237 }
233- } catch ( e ) {
238+ } catch {
234239 // Param not displayed/found
235240 }
236241 }
@@ -244,7 +249,7 @@ export class HasData implements INodeType {
244249 qs [ originalKey ] = additionalFields [ key ] ;
245250 }
246251 }
247- } catch ( e ) {
252+ } catch {
248253 // additionalFields not found
249254 }
250255
@@ -261,17 +266,21 @@ export class HasData implements INodeType {
261266 }
262267 }
263268
264- const response = await this . helpers . requestWithAuthentication . call ( this , 'hasDataApi' , {
265- method,
266- baseURL : 'https://api.hasdata.com' ,
267- url : endpoint ,
268- qs,
269- body : method === 'POST' ? body : undefined ,
270- json : true ,
271- } ) ;
269+ const responseData = await this . helpers . httpRequestWithAuthentication . call (
270+ this ,
271+ 'hasDataApi' ,
272+ {
273+ method,
274+ baseURL : 'https://api.hasdata.com' ,
275+ url : endpoint ,
276+ qs,
277+ body : method === 'POST' ? body : undefined ,
278+ json : true ,
279+ } ,
280+ ) ;
272281
273282 const executionData = this . helpers . constructExecutionMetaData (
274- this . helpers . returnJsonArray ( response as IDataObject [ ] ) ,
283+ this . helpers . returnJsonArray ( responseData as IDataObject [ ] ) ,
275284 { itemData : { item : i } } ,
276285 ) ;
277286 returnData . push ( ...executionData ) ;
0 commit comments