Struggling with even calling a simple function in a workflow

I'm actually trying to make a paginated API call in a workflow with an offset parameter. But when trying to break things down and see why it wasn't successful, I found I couldn't even get a simple one time API function to work with a workflow code block. So, I presume I'm not understanding the docs here: Create functions to reuse queries and logic in workflows | Retool Docs

The value of the view variable does result in a successful API query if I put it in the function1 url parameter field and test it. I presume I am somehow not successfully passing it from the code block to the function.

I think you might also need to add “view” as a parameter in the function.

Thanks, I'll play with this. I guess I assumed the blue 'test' arrow in the top right of code1 wouldn't need a trigger? (but maybe it does or I realize I didn't make it clear that I was just testing it with that arrow for the moment).

Edit update: I have a start trigger that I use to run the code block (I'm not seeing a way to use the start trigger to just call the function). I end up with the same errant result as 'testing' running the code block with the blue arrow.

Thanks. I guess I don't know how to do that outside of how I was trying to do it in the screenshot.

I feel pretty confident the variable value I am trying to pass to the function "viwG9...." is not correctly getting to the api query url parameter field 'view'. I just don't know why.

Hey @Brady_Meisenhelder, you have to add 'view' as a parameter where it says "+ Add parameter" in the function edit window, then it should work.

Ugh! Thanks @Ike2 Not sure how I missed that in the docs demo.

So, in my example, add like this?

(edit: wrong screenshot initially)

(love the error logging console area btw, devs..once I realized it was there I could quickly verify what url is being called by the api query, etc.)

1 Like

All set now. It was that parameter, but also seemed my await call or return statement needed to be of this format:

let result = await function1(view) ;