Calling webhooks

297 views
Skip to first unread message

Alexis L.

unread,
Jan 5, 2017, 12:34:50 AM1/5/17
to back{4}app
Hello Back4app
I'm testing back4app, and having issues getting webhooks to works.

With parse.com, a route such as 

app.get('/hello', function(request, response) {
response.send('Hello World!');
});

and placed in app.js, would be called using myapp.parseapp.com/hello.

The same thing with Back4app results in consistently getting {error:unauthorized}...


Here is my app.js file

var express = require('express');
var path = require('path');
var _ = require('underscore');
var bodyParser = require('body-parser');
var mailgun = require('mailgun-js')({apiKey: "key-xyz", domain: "xyz"});


var moment = require('moment');
var app = express();
// Global app configuration section
app.set('views', './views'); // Specify the folder to find templates
app.set('view engine', 'ejs'); // Set the template engine
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use(express.static(path.join(__dirname,'public')));

app.get('/whatever', function(req, res) {

var query = new Parse.Query("foobar");
query.exists('user');
query.include("user");

query.limit(200);
query.find().then(function(results){
res.send(results);
}, function (error) {
res.send(500,error.message);
});
});

app.get('/hello', function(request, response) {
response.send('Hello World!');
});

app.listen();

Any idea what I did wrong?

casag...@back4app.com

unread,
Jan 9, 2017, 1:03:30 PM1/9/17
to back{4}app
Hello!

Can you please try again removing these lines:


var express = require('express');
var app = express();
app.listen();

And also, changing this line:

app.set('views','./views'); ->to-> app.set('views', __dirname);

Finally, do the other necessary changes after the ones I told you, try again and let me know. :)

Best!

Alexis L.

unread,
Jan 10, 2017, 12:37:51 AM1/10/17
to back{4}app
unfortunately, not working...

Tue Jan 10 2017 05:34:03 GMT+0000 (UTC)
Cloud Code not loaded:
 ReferenceError: app is not defined
    at Object.<anonymous> (/usr/src/app/data/cloud/app.js:12:1)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/src/app/data/cloud/main.js:1:63)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/src/app/cloudCodeWrapper.js:4:20)
    at Module._compile (module.js:409:26)

Tue Jan 10 2017 05:34:03 GMT+0000 (UTC)



casag...@back4app.com

unread,
Jan 10, 2017, 7:04:11 AM1/10/17
to back{4}app
Hello Alexis,

May I ask you how are calling that GET of your app.js? Which URL are you using to call it? Also your app.js is uploaded in your cloud folder, in your app dashboard, right? 

Best!

Alexis L.

unread,
Jan 10, 2017, 11:10:55 AM1/10/17
to back{4}app
Hi,
app.js and main.js are in the cloud folder, at the same path.
Cheers
-A

casag...@back4app.com

unread,
Jan 11, 2017, 10:34:49 AM1/11/17
to back{4}app
Hello,

Actually, now that you've mentioned the main.js, may I ask you if you are require the app.js in your main file? If you are, please remove that and try again. 
That can cause errors like this one that you're informing me.

Best!

Alexis L.

unread,
Jan 11, 2017, 11:48:39 PM1/11/17
to back{4}app
ok, that was it. 

It doesn't make much sense to include it silently, it's confusing. Anyway, for what it's worth, if your team could put together a basic demo app where all the differences between parse and back4app are explicitly coded, that would really be helpful. We all use the same features, albeit for different purposes, so I don't think that would take a lot of efforts.

That would save everyone's time as well, including yours.
thanks for the help. Cheers.

casag...@back4app.com

unread,
Jan 12, 2017, 7:19:34 AM1/12/17
to back{4}app
Hello!

Glad to know it helped you. :)
Thanks for the feedback, we'll work on implementing something like a demonstration about those specific changes needed.

Best!
Reply all
Reply to author
Forward
0 new messages