parse-platform - response.error 不是 Parse Cloud Code 中的函数
问题描述
我正在运行解析服务器并尝试创建解析云代码功能。我从这个过于简单的例子开始:
Parse.Cloud.define("createContent", function(request, response) {
response.error("not implemented");
});
我可以使用带有 curl 的 REST API 调用我的函数,并获取带有错误消息的 JSON:({"code":141,"error":"response.error is not a function"}
这不是我预期的错误消息)。经进一步检查response
,对象竟然是null
。
这是日志的相应部分:
error: Failed running cloud function createContent for user undefined with:
Input: {}
Error: {"code":141,"message":"response.error is not a function"} functionName=createContent, code=141, message=response.error is not a function, , user=undefined
error: response.error is not a function code=141, message=response.error is not a function
解决方案
看起来您正在运行最新版本的服务器。请遵循迁移指南:
https://github.com/parse-community/parse-server/blob/master/3.0.0.md
例如,现在您需要编写:
Parse.Cloud.define("createContent", function(request, response) {
throw "not implemented";
});
// also valid
Parse.Cloud.define("createContent", function(request, response) {
throw new Error("not implemented");
});
// returning a rejected promise
Parse.Cloud.define("createContent", function(request, response) {
return Promise.reject("not implemented");
});
推荐阅读
- c# - C# .NET 什么是组织 SQL 查询并拥有干净代码的最佳方式
- python - 如何使用 Matplotlib 从一组代表 x、y 和 z 点的 3 列开始获取等高线图和 3D 图?
- java - 如何正确运行eclipse?
- java - 如何使用带有 URL 的 setbackground 属性
- javascript - 如何在可能是也可能不是数组的元素上动态执行方法?
- css - 如果在 app.component 内,角粘性页脚不再粘性
- xamarin - 记住用户更新 MasterDetail
- php - 使用 PHP 和 curl 从 API 获取 JSON 数据
- r - r/exams 模板 .tex 文件布局的文档在哪里
- data-warehouse - 使用 Fact 和单个公共密钥解决多对多关系