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

Error when trying to retrieve playlists #36

Open
ls12styler opened this issue Sep 27, 2013 · 3 comments
Open

Error when trying to retrieve playlists #36

ls12styler opened this issue Sep 27, 2013 · 3 comments

Comments

@ls12styler
Copy link

Hi again! You guys are probably going to quite bored with my 'issues'.

I'm trying to get the users playlists, but all I keep getting is an empty error when I run my script.

Output:

➜  spode git:(master) ✗ node src/server.js

Error:

My script looks like this:

// Skip all the require stuff
session.login(cred.login, cred.password);

session.once('login', function (err) {
    if(err) this.emit('error', err);

    // I'm logged in, now what?!
    // Let's get a list of playlists!
    var plContainer = session.getPlaylistcontainer();
    plContainer.getPlaylists(function (a) {
        console.log(a);
    });
});

I would expect to see whatever 'a' contains in the callback.

Having followed the code path, it appears as though the error is coming from PlaylistContainer::_readyOrThrow. I'm guessing the sp_playlistcontainer isn't loaded by the time the callback triggers. Any idea why?

Thanks,

@ls12styler
Copy link
Author

I don't suppose anyone has an idea why the error I'm getting is empty? Or more importantly, why it's happening?

@ls12styler
Copy link
Author

I think the problem is that I'm trying to use the Playlistcontainer before it's ready. I've just wrapped the fetching in a setTimeout with a 1000ms timeout and it then works as expected.

@Floby
Copy link
Owner

Floby commented Jan 10, 2014

I must admit i've been lazy at documenting stuff all around.
Maybe @iancole and @ronaldevers can help us out on this, as they've written most of the codebase for playlists.

getPlaylists() should check that all playlists are loaded before calling the callback. Maybe there's something funny going down in the meantime.

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