-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adding JSON stringify to example python function (#6493)
We need a JSON string for the body in order to access it in our response message. See this comment: aws-amplify/amplify-js#6390 (comment) I had this issue with my own function which was returning null on my JSON.stringify(response). I found the above comment and it made it work! i.e. I could access the return body.
- Loading branch information
1 parent
50a5775
commit a6584e2
Showing
2 changed files
with
5 additions
and
2 deletions.
There are no files selected for viewing
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
5 changes: 4 additions & 1 deletion
5
packages/amplify-python-function-template-provider/resources/hello-world/index.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import json | ||
|
||
def handler(event, context): | ||
print('received event:') | ||
print(event) | ||
|
||
return { | ||
'statusCode': 200, | ||
'headers': { | ||
'Access-Control-Allow-Headers': '*', | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Methods': 'OPTIONS,POST,GET' | ||
}, | ||
'body': "Hello from your new Amplify Python lambda!" | ||
'body': json.dumps('Hello from your new Amplify Python lambda!') | ||
} |