Open Hesse opened 10 years ago
Hey
1: pio_engine - This is an oversight, will add a fix over the weekend unless you have time to add...
2: Using when.js which does have catch support should in theory should work. Helper fn here
Example:
prediction.items.recommendation({
pio_uid: 14
, pio_n: 20
, pio_itypes: ''
, pio_latlng: ''
, pio_within: ''
, pio_unit: ''
, pio_attributes: ''
}).then(function (res) {
console.log(res)
}, function (err) {
// error accessible here
});
Or:
prediction.items.recommendation({
pio_uid: 14
, pio_n: 20
, pio_itypes: ''
, pio_latlng: ''
, pio_within: ''
, pio_unit: ''
, pio_attributes: ''
}).then(function (res) {
console.log(res)
}).catch(function (err) {
// error accessible here
});
No the above does not work. I've fixed the doc, I guess I need to issue a pull request.
Here's the error when I try the above catch: │TypeError: Object #
A couple of things...
Your documentation here https://github.com/ShaunBaker/PredictionIO-Node-SDK/blob/master/DOCS.md#fetch-user-recommendations
Is missing the pio_engine param. This is required and I didn't realize this until I used the call back method.
Which leads to the second issue, is there .then().catch() support? I see that on the items.recommendation function if there's an error you call defer.reject(err). That stops the process, but the error message is not accessible. Whats the best way to handle errors when using the promise approach?