javascript - How to do an HTTP request from Parse (Parse Cloud Code)? -
i trying http request parse heroku server. getting error xcode console when calling function "savetodatabase":
myapp[1400:88895] [error]: uncaught init failed:not supported argument (code: 141, version: 1.7.5) parse cloud function failed called generate token error: optional(error domain=parse code=141 "uncaught init failed:not supported argument" userinfo=0x7fd2a2d5abf0 {code=141, originalerror=error domain=nsurlerrordomain code=-1011 "the operation couldn’t completed. (nsurlerrordomain error -1011.)", temporary=0, error=uncaught init failed:not supported argument, nslocalizeddescription=uncaught init failed:not supported argument})
parse.cloud.define("savetodatabase", function(request, response) { var userinformation = { id: 1003 }; var userjson = json.stringify(userinformation); var plz = "success"; return parse.cloud.httprequest({ url: 'https://myapp.herokuapp.com/saveusertodatabase', method: 'post', headers: { 'content-type': 'application/json' }, body: userjson }).then(function(httpresponse) { response.success(httpresponse.text); }, function (error) { console.error('log response: ' + error.text); }); });
below heroku code:
app.post('/saveusertodatabase', function(request, response) { response.status(200).end(); });
this function using invoke parse cloud code:
func savedata) { println("calling savetodatabase...") pfcloud.callfunctioninbackground("savetodatabase", withparameters: ["userid": 1007]) { (object:anyobject?, error: nserror?) -> void in if error == nil { println("no error...") } else { println("this error: \(error)") } } }
i have tried think of. misunderstanding in code?
Comments
Post a Comment