Closed YousefAlsbaihi closed 1 year ago
It's resolved, it turned out that i have to return the whole save() function, so the cloud code would be:
Parse.Cloud.define("createNewUser", async (request) => {
var User = Parse.Object.extend("User");
var us = new User();
us.set("username", request.params.username);
us.set("name", request.params.name);
us.set("email", request.params.email);
us.set("password", request.params.password);
return await us.save();
});
i'm not sure if this is secure or not, but managed to get objectId and Error messages if there is any, however i was confused of the example here
Parse.Cloud.define("averageStars", async (request) => {
const query = new Parse.Query("Review");
query.equalTo("movie", request.params.movie);
const results = await query.find();
let sum = 0;
for (let i = 0; i < results.length; ++i) {
sum += results[i].get("stars");
}
return sum / results.length;
});
this example return a string, how Parse Cloud Php would get result from that ? i haven't tested that example but just observation.
if there is a different approach, i would appreciate it please let me know.
A Cloud Function can return any type, if I'm not mistaken, it doesn't even have to be a JSON. It then depends on your implementation client side to properly handle the response. So the Parse PHP SDK should not expect a certain type for a Cloud Function response.
I'm closing this as it does not seem to be a Parse PHP SDK issue.
New Issue Checklist
Issue Description
I create a cloud function that create users and i called it using PHP, not it's creating users fine and all good in Parse but the response is not there, all i get is error
Steps to reproduce
Create a cloud function using this code
Actual Outcome
Error as explained before
Expected Outcome
fail or success message
Environment
Parse PHP SDK
2.3.2
8.2.0
Server
6.2.1
Ubuntu 20
Digital Ocean
Database
MongoDb
6
Local
Logs