Showing results for 
Show  only  | Search instead for 
Did you mean: 

How get JSON in Workflows and work on it in the next task


Hello, good day, I am starting to work with the workflows, in the example that I am building I make an http request, which results in a JSON file, which is what interests me since it brings all the data I need, my question is how can I get that json and work on it in the next task, I was reviewing the documentation and I see a result function but I can't quite understand how it works, I don't know if anyone has a similar example, thank you very much in advance



Hola Jorge, let me see if I can help a bit.

You can access the results of the previous steps using the following expressions: 

You can use this syntaxis inside the options and parameters of the following steps.

If the returned object has attributes or more properties you can access them as well using something like:

{{ result('task_1').foo }}

Works as well when working with JSON objects. Most of the tasks return a JSON result object.

If you need to work with the previous results inside a Javascript task and code, you can work with something like in this example: 

As you can see you can store the resulting object from a previous task, or even create a new array to store the whole results. In that example they use:

const TASK_ID = 'predict_disk_capacity'; //here you put the name of the previous task

const predResult = await exe.result(TASK_ID); //store the whole result in a new variable
const result = predResult['result']; //a new variable to store only the result part

Then you can work with result to traverse it or access any particular value.

Best regards,

Jose David.


Featured Posts