mirror of
https://github.com/n8n-io/n8n-docs.git
synced 2025-11-20 17:48:34 +00:00
wip
This commit is contained in:
parent
16e18a7a25
commit
48578bbaca
@ -3,15 +3,15 @@
|
||||
!!! note "Programmatic style only"
|
||||
The information in this document is for node building using the programmatic style. It doesn't apply to declarative style nodes.
|
||||
|
||||
While creating nodes it is very commonn to call external APIs or make HTTP requests to other services.
|
||||
It's common to call external APIs or make HTTP requests to other services from a node.
|
||||
|
||||
This plays a major role during node development, maintenance, and improvements.
|
||||
|
||||
We provide a very flexible helper for making HTTP requests that abstracts away most of the complexity with a simple to use interface.
|
||||
n8n provides a flexible helper for making HTTP requests that abstracts away most of the complexity.
|
||||
|
||||
## How to use
|
||||
|
||||
In the node code, inside the `execute` function you can easily call:
|
||||
Call the helper inside the `execute` function:
|
||||
|
||||
```typescript
|
||||
const response = await this.helpers.httpRequest(options);
|
||||
@ -49,16 +49,16 @@ Where `options` is an object in this format:
|
||||
}
|
||||
```
|
||||
|
||||
Where `url` is the only mandatory field. The default method is `GET`.
|
||||
`url` is required. The other fields are optional. The default method is `GET`.
|
||||
|
||||
Some notes about the possible fields:
|
||||
|
||||
- **body**: You can use a regular Javascript Object for JSON payload, a Buffer for file uploads, an instance of FormData for `multipart/form-data` and `URLSearchParams` for `application/x-www-form-urlencoded`.
|
||||
- **headers**: A simple key-value pair.
|
||||
* If `body` is an instance of `FormData` then `content-type: multipart/form-data` is injected automatically.
|
||||
* If `body` is an instance of `URLSearchParams`, then `content-type: application/x-www-form-urlencoded` is added.
|
||||
* To override this behavior, you can set any `content-type` header you wish and it won't be overridden.
|
||||
- **arrayFormat**: If your query string contains an array of data, let's say `const qs = {IDs: [15,17]}`, the values set to `arrayFormat` define how it will be sent.
|
||||
- `body`: you can use a regular JavaScript object for JSON payload, a buffer for file uploads, an instance of FormData for `multipart/form-data`, and `URLSearchParams` for `application/x-www-form-urlencoded`.
|
||||
- `headers`: a key-value pair.
|
||||
* If `body` is an instance of `FormData` then n8n adds `content-type: multipart/form-data` automatically.
|
||||
* If `body` is an instance of `URLSearchParams`, then n8n adds `content-type: application/x-www-form-urlencoded`.
|
||||
* To override this behavior, set a `content-type` header.
|
||||
- `arrayFormat`: if your query string contains an array of data, such as `const qs = {IDs: [15,17]}`, the value of `arrayFormat` defines how n8n sends it.
|
||||
* `indices` (default): `{ a: ['b', 'c'] }` will be formatted as `a[0]=b&a[1]=c`
|
||||
* `brackets`: `{ a: ['b', 'c'] }` will be formatted as `a[]=b&a[]=c`
|
||||
* `repeat`: `{ a: ['b', 'c'] }` will be formatted as `a=b&a=c`
|
||||
|
||||
@ -11,7 +11,7 @@ This checklist helps you build a node that meets the standards for submission to
|
||||
|
||||
<input type="checkbox"> If you're' creating a node requested by a community member, make sure to comment on the feature request in the [community forum](https://community.n8n.io/c/feature-requests/5).</input><br>
|
||||
<input type="checkbox"> Add complementary operations to each resource (for example, create, delete)</input><br>
|
||||
<input type="checkbox"> Check the node works with more than one item using one input.</input><br> [TODO: what does this mean?]
|
||||
<input type="checkbox"> Check the node works with more than one item using one input.</input>[TODO: what does this mean?]<br>
|
||||
<input type="checkbox"> Ensure the parameters have the correct type.</input><br>
|
||||
<input type="checkbox"> Mind the defaults: if the service has a default as true, keep it as true. Changing default values can break the existing workflows of the users.</input><br>
|
||||
<input type="checkbox"> Check if the node disposes of everything. In particular, the node has closed all connections.</input><br>
|
||||
@ -28,42 +28,45 @@ This checklist helps you build a node that meets the standards for submission to
|
||||
<input type="checkbox"> Ensure the indentation is correct. Check this in the editor configuration.</input><br>
|
||||
<input type="checkbox"> Ensure there are no extra spaces. Check this in the editor configuration.</input><br>
|
||||
<input type="checkbox"> Code comment dividers inside if-branches.</input><br>
|
||||
<input type="checkbox"> Use "create/delete" verbs for operations, except for tags, where you should use "add/remove".</input><br>
|
||||
<input type="checkbox"> Use "create/delete" verbs for operations, except for tags, where you should use "add/remove."</input><br>
|
||||
|
||||
## Errors and Outputs
|
||||
|
||||
<input type="checkbox"> Ensure empty API responses return `{ success: true }`.</input><br>
|
||||
<input type="checkbox"> Ensure the node handles and displays error responses correctly (for example, malformed requests, requests with invalid credentials) and use the current format. You can check this by making failing requests to the API.</input><br>
|
||||
<input type="checkbox"> Check if the response can be simplified and add a simplify function (for example, <a href="https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts">SecurityScorecard node</a>).</input><br>
|
||||
<input type="checkbox"> Ensure the node handles and displays error responses (for example, malformed requests, requests with invalid credentials) and use the current format. You can check this by making failing requests to the API.</input><br>
|
||||
<input type="checkbox"> Check if you can simplify the response. If so, add a simplify function (for example, <a href="https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts">SecurityScorecard node</a>).</input><br>
|
||||
<input type="checkbox"> Ensure the response from `Create` is consistent with `Get`.</input><br>
|
||||
<input type="checkbox"> Ensure the response from `Get All` is consistent with `Get`.</input><br>
|
||||
|
||||
## Presentation
|
||||
|
||||
<input type="checkbox"> The primary menu should only contain required parameters.</input><br>
|
||||
<input type="checkbox"> The primary menu shouldn't contain optional parameters.</input><br>
|
||||
<input type="checkbox"> Ensure a JSON object isn't shown in a single column in Table view.</input><br>
|
||||
<input type="checkbox"> Make sure all GetAll operations have the fields `return` and `limit`.</input><br>
|
||||
<input type="checkbox"> Set the property subtitle.</input><br>
|
||||
<input type="checkbox"> Make sure the pagination (if any) is working correctly. Set Limit 1.</input><br>
|
||||
<input type="checkbox"> Make sure the pagination (if any) is working. Set Limit 1.</input><br>
|
||||
|
||||
## Writing
|
||||
|
||||
<input type="checkbox"> Ensure all descriptions are correct and end with a period.</input><br>
|
||||
<input type="checkbox"> Ensure that most descriptions exist, excluding redundant ones.</input><br>
|
||||
<input type="checkbox"> Ensure IDs in displayNames are capitalized (for example: "IDs" not "ids" or "Ids").</input><br>
|
||||
<input type="checkbox"> Ensure that IDs, if multiple, have descriptive qualifiers.</input><br>
|
||||
<input type="checkbox"> Ensure the `name` property in `description` in the node class is written in camelCase.</input><br>
|
||||
<input type="checkbox"> Ensure the file name and the Class name are identical.</input><br>
|
||||
<input type="checkbox"> Capitalize IDs in displayNames (for example: "IDs" not "ids" or "Ids").</input><br>
|
||||
<input type="checkbox"> If there is more than one ID, ensure they have descriptive qualifiers.</input><br>
|
||||
<input type="checkbox"> Ensure the `name` property in `description` in the node class is in camelCase.</input><br>
|
||||
<input type="checkbox"> Ensure the file name and the class name are identical.</input><br>
|
||||
|
||||
## Branding
|
||||
|
||||
<input type="checkbox"> Ensure the name of the service is written correctly (e.g., "GitHub" not "Github"). If the node is a trigger node, ensure it is named as such, by adding "Trigger" after the service name (e.g., "Trello Trigger").</input><br>
|
||||
<!-- vale off -->
|
||||
<input type="checkbox"> Check that brand names are correct (for example, "GitHub" not "Github"). </input><br>
|
||||
<input type="checkbox">If the node is a trigger node, show this in the name by adding "Trigger" after the service name (for example, "Trello Trigger").</input><br>
|
||||
<input type="checkbox"> Ensure the logo is either a PNG or SVG, ideally the latter. <a href="https://vecta.io/symbols">Vecta</a> is a good website to find SVGs of different applications.</input><br>
|
||||
<input type="checkbox"> If the logo is an SVG, ensure the canvas is a perfect square. If the logo is PNG, ensure it is 60x60 pixels and compressed.</input><br>
|
||||
<input type="checkbox"> If the logo is an SVG, ensure the canvas is a perfect square. If the logo is PNG, ensure it's 60x60 pixels and compressed.</input><br>
|
||||
<input type="checkbox"> Ensure the border color of the node matches the branding of the service.</input><br>
|
||||
<!-- vale on -->
|
||||
|
||||
## Nice-to-haves (optional)
|
||||
<input type="checkbox"> Add handler for `continueOnFail`. This feature is included in some of the newest nodes (e.g <a href="https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts">Lemlist node</a>) to continue the workflow even if the node's execution fails.</input><br>
|
||||
<input type="checkbox"> Remove `required: false` and `description: ''` in the node descriptions (e.g., <a href="https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/nodes/Lemlist/descriptions">Lemlist node</a>).</input><br>
|
||||
|
||||
<input type="checkbox"> Add handler for `continueOnFail`. This handler continues the workflow even if the node's execution fails.</input><br>
|
||||
<input type="checkbox"> Remove `required: false` and `description: ''` in the node descriptions (for example, <a href="https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/nodes/Lemlist/descriptions">Lemlist node</a>).</input><br>
|
||||
<input type="checkbox"> At call site, specify first `body` and then `qs`.</input><br>
|
||||
<input type="checkbox"> At call site, prepend the endpoint with slash `/` (e.g., "/campaign").</input><br>
|
||||
<input type="checkbox"> At call site, prepend the endpoint with slash `/` (for example, "/campaign").</input><br>
|
||||
@ -5,8 +5,10 @@ Enum
|
||||
enum
|
||||
GIMP
|
||||
invalid
|
||||
Lemlist
|
||||
n8n
|
||||
namespace
|
||||
npm
|
||||
onboarding
|
||||
Trello
|
||||
URL
|
||||
Loading…
Reference in New Issue
Block a user