Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for catch? And documentation is incorrect.. #13

Open
Hesse opened this issue Sep 10, 2014 · 2 comments
Open

Support for catch? And documentation is incorrect.. #13

Hesse opened this issue Sep 10, 2014 · 2 comments

Comments

@Hesse
Copy link

Hesse commented Sep 10, 2014

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?

@ShaunBaker
Copy link
Owner

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
});

@Hesse
Copy link
Author

Hesse commented Sep 10, 2014

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 # has no method 'catch'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants