gpt4 book ai didi

javascript - 执行无误后不调用回调

转载 作者:行者123 更新时间:2023-11-30 16:56:19 30 4
gpt4 key购买 nike

我正在努力处理以下代码。请求已发送但未调用回调。我也没有收到任何错误,但已发送电子邮件!你有什么想法吗?

var userPointer = webhook.get("user");
userPointer.fetch().then(function(user){

Parse.Cloud.httpRequest({
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
url: 'https://mandrillapp.com/api/1.0/messages/send-template.json',
body: {
template_name: webhook.get("mandrillTemplateSlug"),
template_content: null,
key: user.get("apiKey"),
message: {
subject: webhook.get("subject"),
from_email: "example@mail.com",
from_name: "System",
to: userData
},
async: false
}
},{
success: function(httpResponse) {
console.log(httpResponse);
},
error: function(error){
console.log(error);
}
});
});

最佳答案

您已将选项对象分成两个单独的对象:

Parse.Cloud.httpRequest({
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
url: 'https://mandrillapp.com/api/1.0/messages/send-template.json',
body: {
template_name: webhook.get("mandrillTemplateSlug"),
template_content: null,
key: user.get("apiKey"),
message: {
subject: webhook.get("subject"),
from_email: "example@mail.com",
from_name: "System",
to: userData
},
async: false
}
}, { // <=== Remove these, replace with just a comma
success: function(httpResponse) {
console.log(httpResponse);
},
error: function(error) {
console.log(error);
}
});

应该只有一个,像这样:

Parse.Cloud.httpRequest({
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
url: 'https://mandrillapp.com/api/1.0/messages/send-template.json',
body: {
template_name: webhook.get("mandrillTemplateSlug"),
template_content: null,
key: user.get("apiKey"),
message: {
subject: webhook.get("subject"),
from_email: "example@mail.com",
from_name: "System",
to: userData
},
async: false
},
success: function(httpResponse) {
console.log(httpResponse);
},
error: function(error) {
console.log(error);
}
});

关于javascript - 执行无误后不调用回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29672011/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com