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

Cannot get videosIndex value from Promise - IOS #228

Closed
serialbandicoot opened this issue Oct 16, 2017 · 4 comments
Closed

Cannot get videosIndex value from Promise - IOS #228

serialbandicoot opened this issue Oct 16, 2017 · 4 comments

Comments

@serialbandicoot
Copy link

Inside getProgress(e), I'm calling const vId = this._youTubeRef.videosIndex();

However the Promise is returning the following and I can't figure out how to extract the actual index.

Promise {_40: 0, _65: 0, _55: null, _72: null}
_40: 0
_55: 4
_65: 1
_72: null

I know that _55 is storing the Index Value as I can move through the track index and it changes as I change the current played track.

I just don't know how to get to it!...

I've tried all sorts of ways to get the value, but cannot figure it out - anyone know how to extract it?

Many thanks....

@davidohayon669
Copy link
Owner

@serialbandicoot videosIndex() returns a Promise, and promises needs to be chained with .then(), or being await-ed inside an async function.
What you are setting vId to is only the promise itself, not the resolved value of it.

@serialbandicoot
Copy link
Author

That's brilliant! I'm a bit new to javascript, however this is really well explained and makes perfect sense.

this._youTubeRef.videosIndex().then(function(result){
console.log(result);
});

I was going to suggest putting an example in the docs and when I looked there it was!...

Many thanks...

@bashirpour
Copy link

I had the same problem and solved using then problems.
res.text().then((result)=>{ console.log(result); })

res is my promise data

@mrvijaycode
Copy link

I had the same problem and solved using then problems.
res.text().then((result)=>{ console.log(result); })

res is my promise data

If i want to return the res.text , how can i do? Please can you post

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

4 participants