Hi all. I am currently building my first custom node and am a bit stuck with the execution development part. Also, newbie in TS.
Have been trying to refer to the code of other nodes, but that’s not enough.
E.g. built an ApiRequest function in GenericFunctions.ts to dynamically load options in the node. But it doesn’t work at all.
How to go about debugging this?
Usually, i would just console.log the various steps but that doesn’t seem to work in this situation.
Also, my code in the ApiRequest functions keeps giving errors for custom properties, like:
n8n-nodes-base: nodes/Directus/GenericFunctions.ts(37,24): error TS2339: Property 'url' does not exist on type 'Promise<ICredentialDataDecryptedObject | undefined>'.
n8n-nodes-base: nodes/Directus/GenericFunctions.ts(38,32): error TS2339: Property 'accessToken' does not exist on type 'Promise<ICredentialDataDecryptedObject | undefined>'.
n8n-nodes-base: nodes/Directus/GenericFunctions.ts(53,59): error TS2339: Property 'data' does not exist on type 'RequestPromise<any>'.
This change was introduced this week with #1741. Hopefully the tutorial can be updated soon @harshil1712
Regarding the TS error on L53, you are accessing data on the unawaited result of calling this.helpers.request(). The promise has not resolved by then, so the property access fails. You can await the result and then access it, or preferably return the raw response and let the caller decide what to do with data, since maybe not all endpoints return this property.
return await this.helpers.request!(options);
Regarding load options, with the L53 fix the call should succeed, giving you access to the collections data on the load options side. Let me know otherwise.
I’ve come across another issue with my setup.
After multiple changes, my node is now stuck. I can see the options for Resource and Operation but can’t select any of them.
Would appreciate any insight regarding this error:
Error: Could not resolve parameter depenencies. Max itterations got reached!
at u (NodeHelpers.js:372)
at c (NodeHelpers.js:402)
at c (NodeHelpers.js:399)
at Object.c [as getNodeParameters] (NodeHelpers.js:460)
at s.valueChanged (NodeSettings.vue:358)
at rt (vue.runtime.esm.js:1863)
at s.n (vue.runtime.esm.js:2188)
at rt (vue.runtime.esm.js:1863)
at s.Tn.e.$emit (vue.runtime.esm.js:3903)
at s.valueChanged (ParameterInputList.vue:220)
What to make of this? And where, in my code, could the issue be?
Have now managed to bring down 300+ linting errors to 6.
But, can’t seem to resolve the remaining errors, even though everything seems to be configured properly.
After doing this and rebuilding, still getting the same error. Particularly, the node gets stuck once the Field resource is selected.
Also, while checking with the nodelinter (npx nodelinter), still getting those 6 errors, including this one:
├── 203 ERROR: Param with non-existent `loadOptionsMethod`
│ The method to load options specified for this param has not
│ been defined in `methods.loadOptions` in the node.
│ loadOptionsMethod: 'getCollections'
Regarding the loadOptionsMethod linting, thank you, it was also reported by another user today. Will disable it soon until fixed - feel free to ignore it.
Regarding the max iterations error, if I run the linter against the version I received today (i.e. in your second PM), I see ~300 lintings instead of 6. Is it possible the code you shared today is not your latest?
For reference, the max iterations fix in my previous message is based on today’s version and I can confirm it works there. Sending you the branch via PM.