Skip to content

Instantly share code, notes, and snippets.

@chapimenge3
Last active December 4, 2022 17:52
Show Gist options
  • Save chapimenge3/b20d9fbb971f0e99eaa9072059bc1788 to your computer and use it in GitHub Desktop.
Save chapimenge3/b20d9fbb971f0e99eaa9072059bc1788 to your computer and use it in GitHub Desktop.
'''
this goes to Below the create_todo function
'''
def list_todo(event, context):
'''
List Todo Application in Dynamo DB
Params:
event: API Gateway Event
context: Lambda Context
Return:
response: API Gateway Response
response.body: JSON String
message: String
todos: List | None
error: Boolean|String
'''
try:
# list all todo
response = table.scan()
todos = response['Items']
# return todos
response = {
'statusCode': 200,
'body': json.dumps({
'todos': todos,
'error': False
})
}
return response
except Exception as e:
# return error
response = {
'statusCode': 400,
'body': json.dumps({
'message': str(e),
'error': True
})
}
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment