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....
@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.
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...
I had the same problem and solved using then problems.
res.text().then((result)=>{
console.log(result);
})
res is my promise data
I had the same problem and solved using
thenproblems.
res.text().then((result)=>{ console.log(result); })
resis my promise data
If i want to return the res.text , how can i do? Please can you post
Most helpful comment
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...