Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

response.error is not a function in Parse Cloud Code

I'm running parse-server and trying to create a parse cloud code function. I started with this oversimplified example:

Parse.Cloud.define("createContent", function(request, response) {
  response.error("not implemented");
});

I can call my function using the REST API with curl and get a JSON with an error message: {"code":141,"error":"response.error is not a function"} (this is not the error message I expected). Upon further examination response object turned out to be null.

This is the respective section of the log:

error: Failed running cloud function createContent for user undefined with:
Input: {}
Error: {"code":141,"message":"response.error is not a function"} functionName=createContent, code=141, message=response.error is not a function, , user=undefined
error: response.error is not a function code=141, message=response.error is not a function
like image 485
CYB3R Avatar asked Sep 08 '26 23:09

CYB3R


1 Answers

It looks like you're running the latest version of the server. Please follow the migration guides:

https://github.com/parse-community/parse-server/blob/master/3.0.0.md

For example, now you'll need to write:

Parse.Cloud.define("createContent", function(request, response) {
  throw "not implemented";
});

// also valid
Parse.Cloud.define("createContent", function(request, response) {
  throw new Error("not implemented");
});

// returning a rejected promise
Parse.Cloud.define("createContent", function(request, response) {
  return Promise.reject("not implemented");
});
like image 149
flovilmart Avatar answered Sep 13 '26 06:09

flovilmart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!