So I'm unable to find any examples and the example used on the npm package README throws me an error.
So I'm using https://github.com/Datahero/node-eventbrite
I require it in app.js. I create the token variable and place my token in there.
I add this piece of snippet in
try {
var api = eventbriteAPI({
token: eventbrite_token,
version : 'v3'
});
} catch (error) {
console.log(error.message); // the options are missing, this function throws an error.
}
So on the README file it says the next line of code should be something like (replacing the user_id: with my user id).
api.owned_events({ user_id: 30 }, function (error, data) {
if (error)
console.log(error.message);
else
console.log(JSON.stringify(data)); // Do something with your data!
});
I get the error TypeError: api.owned_events is not a function
Basically I'm trying to get a list of events based on the location from the Eventbrite API via node. But I'm unable to even query from node and get what I want back. Has anyone any resources or can offer help?
Thank you!
I think there is an error on the README file, api should be declared outside the try/catch block:
var api;
try {
api = eventbriteAPI({
token: eventbrite_token,
version : 'v3'
});
} catch (error) {
console.log(error.message);
}
api.owned_events({ user_id: 30 }, function (error, data) {
if (error)
console.log(error.message);
else
console.log(JSON.stringify(data)); // Do something with your data!
});
Related
I've had this problem for almost a day and I don't know what else to do to solve it.
Dialogflow Fulfillment in Dialogflow ES just doesn't want to make any HTTP calls at all. I'm always getting this error: No responses defined for platform: DIALOGFLOW_CONSOLE
My entired code is below. The function that crash everything is:
function simpleGet(requestUrl) {
axios.get(https://eo1lbzchsaeazi9.m.pipedream.net/)
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
}
function simpleGet(requestUrl) {
axios.get(https://eo1lbzchsaeazi9.m.pipedream.net/)
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
}
sorry, there is some context missing here.
do you see the error message when trying to use fullfilments (ie. one API call to get on a backend an answer to a customer interaction?
Also, another clarifying question - is it Dialogflow ES or CX?
I've seen some developers struggling with this error and some of them fixed it by updating the package for fulfillments as described here: https://github.com/dialogflow/dialogflow-fulfillment-nodejs/issues/322
I'm trying to load some js files by dynamic path using require
try {
require([`views/Report/${path}/filterProps.js`], function(data) {
console.log(props);
});
} catch (error) {
console.log(error);
}
the path is a usual string (for instance 'file1')
everything is fine but when the file does not exist it thrown the error.
I have tried try-catch but it didn't solve the problem.
Any idea to solve the problem?
update
this how it worked for me:
require.onError = function(err) {
console.log(err);
};
require([`views/Report/${path}/filterProps.js`], function(data) {
console.log(props);
});
I am writing an updated testing library for Node.js and am trying to properly trap errors that occur in test callbacks
for some reason, the following code doesn't trap an AssertionError:
process.on('uncaughtException',function(err){
console.error(err); //an instance of AssertionError will show up here
});
[file1,file2,file2].forEach(function (file) {
self.it('[test] ' + path.basename(file), {
parallel:true
},function testCallback(done) {
var jsonDataForEnrichment = require(file);
request({
url: serverEndpoint,
json: true,
body: jsonDataForEnrichment,
method: 'POST'
}, function (error, response, body) {
if (error) {
done(error);
}
else {
assert(response.statusCode == 201, "Error: Response Code"); //this throws an error, which is OK of course
done();
}
});
});
});
I handle the callback (I named it "testCallback" above), with this code:
try {
if (!inDebugMode) {
var err = new Error('timed out - ' + test.cb);
var timer = setTimeout(function () {
test.timedOut = true;
cb(err);
}, 5000);
}
test.cb.apply({
data: test.data,
desc: test.desc,
testId: test.testId
}, [function (err) { //this anonymous function is passed as the done functon
cb(err);
}]);
}
catch (err) { //assertion error is not caught here
console.log(err.stack);
cb(err);
}
I assume the problem is that callbacks that result from async functions like those made in the request module, cannot be trapped by simple error handling.
What is the best way to trap that error?
Should I just flesh out the process.on('uncaughtException') handler? Or is there a better way?
The best way to handle this appears to be Node.js domains, a core module
https://nodejs.org/api/domain.html
it will likely be deprecated soon, but hopefully there will be a replacement that can have similar functionality, because the domain module is saving my ass right now, as I have no other way to trap errors, because the errors might be generated by my users' code, not my code.
I'm trying to return the error object inside the response of a boom internal error object but it keeps omitting the error object.
I tried to follow the answer here but it didn't help.
function (request, reply) {
options.healthCheck(function (err) {
if (!err) {
return reply('I\'m healthy!!!');
}
var boomErr = boom.internal('I don\'t feel so good', {
err: err
});
boomErr.output.payload.details = err;
return reply(boomErr);
});
}
Here is the response:
{
"statusCode":500,
"error":"Internal Server Error",
"message":"An internal server error occurred",
"details":{ }
}
After digging into boom docs, I found out that all 5xx errors hide the custom message and payload.
Switching to bad request error solved my issue.
I'm trying to run Parse cloud code for the first time from an AngularJS app. I keep getting the Parse.Error 'unauthorized' in my console.log. I've initialized Parse in my application and JS keys. Where am I going wrong?
Angular Code Format:
$scope.runSomething = function () {
Parse.Cloud.run('nameFunction', req.body, {
success: function (result){
},
error: function (error){
console.log(error);
}
})
I derive the req.body for the Parse.Cloud.run from prestanding info in the $scope.runSomething function.
My truncated main.js:
Parse.Cloud.define('nameFunction', function(request, response){
Parse.Cloud.useMasterKey();
//Do Stuff})
I'm sure I'm missing something small but I have no idea what.
It sounds like you're close. Cloud functions (including before/after functions) must call success or error on the response object to properly complete, so...
Parse.Cloud.define('nameFunction', function(request, response){
Parse.Cloud.useMasterKey();
var someParam = request.params.someParam;
doSomePromiseReturningThing(someParam).then(function(result) {
response.success(result);
}, function (error) {
response.error(error);
});
});