Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Pipedream
Pipedream

Posted on • Originally published atblog.pipedream.com

     

Export data from a loop

Pipedream makes it easy to build event-driven workflows with managed auth (just connect your account and reference tokens and keys in code!). Data is passed between steps in a workflow usingstep exports, which can be inspected and referenced by later steps. In this post, I'll explain how to export data from a loop:

There are two ways to export data from a loop in a Node.js code step on Pipedream:

  1. Use a step export array
  2. Return an array object after the loop is complete

Use a step export array

To export data from a loop using step exports:

  1. Define a step export as an array
  2. Add the data you want to export for each loop execution to that array
  3. Export the array
this.testExport = []for (let i=0; i < 5; i++) {  this.testExport.push(i)}

When your workflow executes, the step will export an array atsteps.STEP_NAME.testExport with a length of5 and values from0 -4.

Copy and run this workflow to test it out. On each loop execution, the code makes an Axios request to theStar Wars API, and it assigns the response data tosteps.example.testExport:

https://pipedream.com/@pravin/export-axios-response-data-from-a-loop-p_G6C1bG/edit

Return an array object after the loop is complete

To return an array after the loop is complete:

  1. Define an array
  2. Add the data you want to export for each loop execution to that array
  3. Return the array
data = []for (let i=0; i < 5; i++) {  data.push(i)}return i

When your workflow executes, the step will export an array atsteps.STEP_NAME.$return_value with a length of5 and values from0 -4.

Copy and run this workflow to test it out. On each loop execution, the code makes an Axios request to theStar Wars API, and it assigns the response data tosteps.example.$return_value:

https://pipedream.com/@pravin/return-axios-response-data-from-a-loop-p_NMC2Yy/edit

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Pipedream is an integration platform for developers. Develop any workflow, based on any trigger, with no infra.
  • Location
    San Francisco, CA
  • Joined

More fromPipedream

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp