Parse platform 解析集成第三方服务
我目前正在学习教程 在模块中,sendEmail功能设置如下:Parse platform 解析集成第三方服务,parse-platform,parse-cloud-code,Parse Platform,Parse Cloud Code,我目前正在学习教程 在模块中,sendEmail功能设置如下: sendEmail: function(params, options) { return Parse.Cloud.httpRequest({ method: "POST", url: "https://api:" + key + "@" + url + "/" + domain + "/messages", body: params, }).then(function(httpResponse) {
sendEmail: function(params, options) {
return Parse.Cloud.httpRequest({
method: "POST",
url: "https://api:" + key + "@" + url + "/" + domain + "/messages",
body: params,
}).then(function(httpResponse) {
if (options && options.success) {
options.success(httpResponse);
}
}, function(httpResponse) {
if (options && options.error) {
options.error(httpResponse);
}
});
}
每当我使用curl运行函数并尝试console.log选项散列时,选项散列总是未定义的
结果是我无法在回调中获取httpResponse对象
Parse.Cloud.define("sendEmailToUser", function(request, response) {
client.sendEmail({
to: "email@example.com",
from: "MyMail@CloudCode.com",
subject: "Hello from Parse!",
text: "Using Parse and My Mail Module is great!"
}).then(function(httpResponse) {
response.success("Email sent!");
}, function(httpResponse) {
console.error(httpResponse);
response.error("Uh oh, something went wrong");
});
});
如何在上面的回调中获取httpResponse对象?您只需返回得到的结果,然后它将继续传递给下一个成功/错误处理程序
sendEmail: function(params, options) {
return Parse.Cloud.httpRequest({
...
}).then(function(httpResponse) {
if (options && options.success) {
options.success(httpResponse);
}
return httpResponse
}, function(httpResponse) {
if (options && options.error) {
options.error(httpResponse);
}
return httpResponse
});
}