steps
argument passed to the run({ steps, $ })
function.
In this example, we’ll pretend this data is coming into our HTTP trigger via POST request.
steps
variable Specifically, this data from the POST request into our workflow is available in the trigger
property.
return
it.
$.export
helper instead of returning data. The $.export
creates a named export with the given value.
pokemon
data is accessible to downstream steps within steps.code.pokemon
/tmp
directory.firstName
prop. This will allow us to freely enter text from the workflow builder.
firstName
to this particular step only:
run
method:
await
keyword or with a Promise chain, using .then()
, .catch()
, and related methods.steps
variable to the run method. steps
is also an object, and contains the data exported from previous steps in your workflow.$
variable, which gives you access to methods like $.respond
, $.export
, and more.this
, which refers to the current step:
this.appName.$auth
.
console.log
or console.error
to add logs to the execution of a code step.
These logs will appear just below the associated step. console.log
messages appear in black, console.error
in red.
console.dir
console.dir
:
npm
packagesimport
itimport
it:
require
it:
import
or require
statements, not both. See this section for more details.
When Pipedream runs your workflow, we download the associated npm package for you before running your code steps.
If you’ve used Node before, you’ll notice there’s no package.json
file to upload or edit. We want to make package management simple, so just import
or require
the module like you would in your code, after package installation, and get to work.
README
, but often it’s not. If you’re not sure and need to use it, we recommend just trying to import
or require
it.
Other packages require access to binaries or system libraries that aren’t installed in the Pipedream execution environment.
If you’re seeing any issues with a specific package, please let us know and we’ll try to help you make it work.
import
in your step. By default, Pipedream deploys the latest version of the npm package each time you deploy a change.
There are many cases where you may want to specify the version of the packages you’re using. If you’d like to use a specific version of a package in a workflow, you can add that version in the import
string, for example:
^
) operator is different for 0.x versions, for which it will only match patch versions, and not minor versions.require
statement:
axios
CommonJS module published to npm. You import CommonJS modules using the require
statement.
But you may encounter this error in workflows:
Error Must use import to load ES Module
This means that the package you’re trying to require
uses a different format to export their code, called ECMAScript modules (ESM, or ES modules, for short). With ES modules, you instead need to import
the package:
import
, you’re less likely to have problems. In general, refer to the documentation for your package for instructions on importing it correctly.
require
is not definedrequire is not defined
error. There are two solutions:
require
statement into an ESM import
statement. For example, convert this:import
syntax fails to work, separate your imports into different steps, using only CommonJS requires in one step, and only ESM imports in another.axios
to make HTTP requests.$.send.http()
, a Pipedream-provided method for making asynchronous HTTP requests.$.send.http()
. If you need to operate on the data in the HTTP response in the rest of your workflow, use axios
.
$.respond()
function.
$.flow.trigger
:
user_id
contained in the event to look up information in an external API. If you can’t find data in the API tied to that user, you don’t want to proceed.return $.flow.exit()
will end the execution of the workflow immediately. No remaining code in that step, and no code or destination steps below, will run for the current event.
return $.flow.exit()
to immediately exit the workflow. In contrast, $.flow.exit()
on its own will end the workflow only after executing all remaining code in the step.$.flow.exit()
:
ConfigurationError
in a Node.js step will display the error message in a dedicated area.
This is useful for providing feedback during validation of props
. In the example below, a required Header value is missing from the Google Sheets action:
email
prop:
process.env.VARIABLE_NAME
. The values of environment variables are private.
See the Environment Variables docs for more information.