I guys. I'd like to share my experience using Step...
# help
j
I guys. I'd like to share my experience using Step Functions. If you write a async function, you can return its result without resolve it using await. Just do something like that:
Copy code
export function handler (event: any) {
  return myAsyncFunction(event)
}
But, when working with a synchronous function (that does not return a Promise) is necessary to use something like that:
Copy code
import { Callback, Context } from 'aws-lambda';

export function handler (event: any, context: Context, callback: Callback) {
  const output = mySyncFunction(event)
  callback(null, output)
}
If you try to return the result directly, you will get a null input in the next step.
t
In the second example you can mark the function
async
and you should just be able to return
output
export async function handler
j
Nice trick! Thanks
r
Or if the linter complains about a async definition on a function that doesn't contain an await you can return Promise.resolve(output)