Search code examples
node.jsexpressparse-platformparse-server

Express API timeout despite success callback


I have an express API:

var bodyParser = require("body-parser");
app.use(bodyParser.json());
app.post("/adapter/mail", function(request, response) {

    var body = request.body;
    var id = body.id;
    var params = {id: id};

    Parse.Cloud.run("email", params, {
        success: function(e) {
            console.log("api: success");
            respone.status(200).send("e");
        },
        error: function(e) {
            console.log("api: error: " + JSON.stringify(e));
            response.status(500).send(e);
        }
    });
});

Calling the API calls the Parse Cloud Code:

Parse.Cloud.define("email", function(request, response) {
    console.log(JSON.stringify(request, null, 4));
    response.success("ok");
});

In the console I see that console.log("api: success"); gets executed correctly, but the API request does not end, it times out despite the successful callback.

When Cloud Code returns response.error("error"); instead of response.success("ok"); the request does not timeout but ends immediately.

Why does the request time out on success?


Solution

  • Looks like you are missing an "s" on your callback

    respon"s"e.status(200).send("e");