gpt4 book ai didi

javascript - 未返回 Parse.com http 响应,未定义状态

转载 作者:行者123 更新时间:2023-11-29 14:53:13 25 4
gpt4 key购买 nike

我在用 parse 编写后台作业时遇到了 2 个问题

这是我的代码

Parse.Cloud.job("createSilentUsers",function(request,response){

// Set up to modify user data
Parse.Cloud.useMasterKey();

//get all the users from backupusers table where isbiscootactivated = 0 and issnsactivated=0
// Query for all users
var query = new Parse.Query("biscootusers");
query.equalTo("isbiscootactivated",0);
query.equalTo("issnsactivated",0);
query.first({
success: function(result) {
// Successfully retrieved the object.
var objUser = result;
console.log(result.attributes.deviceid);
console.log(result.attributes.imei);
console.log(result.attributes.appname);
console.log(result.attributes.appid);
console.log(result.attributes.appversion);

//check if the deviceid and imei set is already a biscoot activated user
var promise = Parse.Promise.as();
promise = promise.then(function() {
console.log("we are inside the prmise");
return Parse.Cloud.httpRequest({
method: 'POST',
url: 'http://<our server name>/1.0/PartnerActivation/isDeviceExists',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'},
body: {
imei: result.attributes.imei,
deviceid: result.attributes.deviceid,
appname: result.attributes.appname,
appid: result.attributes.appid,
appversion: result.attributes.appversion}
}).then(function(httpResponse)
{
console.log("Response of isdeviceactivated is " + httpResponse.text);
if(httpResponse.text == 'true' || httpResponse.text="True")
{
console.log("The user is already activated");
objUser.set("isbiscootactivated",1);
objUser.save();
}
else
{
//do the biscoot activation here
console.log("its not activated, lets do the biscootusers activation");
}
},
function(error) {
console.log("error occurred during isDeviceExists api as " + error);
});
});

console.log("nothing seems to have happened");

},
error: function(error) {
console.log("Error: " + error.code + " " + error.message);
}
}).then(function() {
// Set the job's success status
status.success("All the users been set to the db successfully");
}, function(error) {
// Set the job's error status
status.error("Uh oh, something went wrong.");
});
});

我遇到的问题是

  1. 在日志中我经常看到这个错误

    使用以下命令运行作业 createSilentUsers: 输入: {} 失败:ReferenceError:状态未定义 在 main.js:74:9 在 r (Parse.js:2:4981) 在 Parse.js:2:4531 在 Array.forEach( native ) 在 Object.E.each.E.forEach [as _arrayEach] (Parse.js:1:666) 在 n.extend.resolve (Parse.js:2:4482) 在空。 (Parse.js:2:5061) 在 r (Parse.js:2:4981) 在 n.extend.then (Parse.js:2:5327) 在 r (Parse.js:2:5035)

  2. http 请求似乎不起作用,但如果我从一些 http REST 客户端测试它,它总是起作用。

最佳答案

只需将函数 header 上的“响应”更改为“状态”即可。

Parse.Cloud.job("createSilentUsers",function(request,response){

对此

Parse.Cloud.job("createSilentUsers",function(request,status){

关于javascript - 未返回 Parse.com http 响应,未定义状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21979615/

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