Skip to content

Commit 1487a73

Browse files
committed
Fix expected webhook external response format (#1934)
1 parent 50b9ae4 commit 1487a73

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

spec/ParseHooks.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ describe('Hooks', () => {
381381
object.hello = "world";
382382
// Would need parse cloud express to set much more
383383
// But this should override the key upon return
384-
res.json({success: {object: object}});
384+
res.json({success: object});
385385
});
386386
// The function is delete as the DB is dropped between calls
387387
Parse.Hooks.createTrigger("SomeRandomObject", "beforeSave" ,hookServerURL+"/BeforeSaveSome").then(function(){

src/Controllers/HooksController.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function wrapToHTTPRequest(hook, key) {
190190
request.post(hook.url, jsonRequest, function (err, httpResponse, body) {
191191
var result;
192192
if (body) {
193-
if (typeof body == "string") {
193+
if (typeof body === "string") {
194194
try {
195195
body = JSON.parse(body);
196196
} catch (e) {
@@ -204,6 +204,8 @@ function wrapToHTTPRequest(hook, key) {
204204
}
205205
if (err) {
206206
return res.error(err);
207+
} else if (hook.triggerName === 'beforeSave') {
208+
return res.success({object: result});
207209
} else {
208210
return res.success(result);
209211
}

0 commit comments

Comments
 (0)