"error": "Invalid scf response. expected scf response valid JSON."腾讯云函数

这两天开始研究腾讯云的云函数了,因为要做一个小程序,感觉用云函数是种不错的选择,也就调用下API从数据库里面取点数据并返回,省去了很多麻烦。

然后返回Json时遇到了

"error": "Invalid scf response. expected scf response valid JSON."

经百度,原来是返回是需要加上json.dumps才可以

代码语言:javascript
复制
return {
    "isBase64Encoded": False,
    "statusCode": 200,
    "headers": {"Content-Type": "application/json"},
    "body": json.dumps({'result': result})
}
image.png