Last active
December 4, 2022 17:52
-
-
Save chapimenge3/b20d9fbb971f0e99eaa9072059bc1788 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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