You need to specify a json string and the memetype so that it can be returned as a json.
Here is an example.
@https_fn.on_request()
def on_request_get_profile(req: https_fn.Request) -> https_fn.Response:
# Form dictionary
response_dict = {"Name": "MyName", "Age": 30}
json_response = json.dumps(response_dict)
return https_fn.Response(json_response, mimetype='application/json')
That is all you really need but I will add more information here should ___.
You will probably be doing this in many places so I suggest you create a little helper function for this.
def form_response(data):
return json.dumps(data)
Then whenever you need to return some data, you can use this helper function like so.
@https_fn.on_request()
def on_request_get_profile(req: https_fn.Request) -> https_fn.Response:
# Perform your logic to produce the response.
response = {"Name": "MyName", "Age": 30}
return https_fn.Response(form_response(json_response ), mimetype='application/json')
Do note that it is not required to pass a python dictionary or json object to form_response method.
Do you want to try a str or list object?