I was trying to build a function which can return array of dictionaries instead of only one dictionary as per the below tutorial https://github.com/digitalocean/sample-functions-python-jokes I can return
import pyjokes
def main(args):
joke = pyjokes.get_joke()
return {
'body': {
'response_type': 'in_channel',
'text': joke
}
}
I get this error
{
"result": {
"error": "The function did not return a dictionary."
},
"size": 54,
"status": "action developer error",
"success": false
}
I need something like
return [{
'body': {
'response_type': 'test1',
'text': 'joke'
}
},
{
'body': {
'response_type': 'test2',
'text': 'no-joke'
}
}]
is this possible with serverless functions?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
You can have just one
body
and inside thebody
you can pass your dictionary, for example:The response when you visit/trigger the function will be:
Hope that this helps! Let me know how it goes.
Best,
Bobby