I have an AWS Lambda function in python3.7. The way its set up im running the lambda_handler(event, context) function and passing data to a separate function that calls itself multiple times depending on what is passed into it. How do I then return data from the second function?
import json
import boto3
def lambda_handler(event, context):
# code to get initial data
x = second_function(data)
print(x)
return x
def second_function(data):
# code to manipulate data
if condition:
print(newData)
second_function(newData)
else:
return allData
I expected this to return allData back through the lambda_handler function, but instead returns null
And logged is
newData
newData
newData
None
I am using the second function to get data based on the last PaginationToken. Is there a better way to get paginated data rather than creating a second recursive function?
second_function()doesn't seem to return anything ifconditionis true. And ifconditionis false, it appears thatallDatais empty (None).