How to Remove the Promise <Hoge> Hoge

Asked 2 years ago, Updated 2 years ago, 68 views

Please let me know if there is a site that explains how to use Promise<>.

There is a function called hogeFunction, which returns Promise<T>.

I'd like to use the value of type T for this function, but Promise is interrupting me and I can't take it out.
I can't use functions with arguments in Then, so I still can't take out Tt...
Please let me know if there is a good way.

javascript typescript

2022-09-30 21:42

1 Answers

Please let me know if there is a website that explains how to use Promise <>

The detailed usage of MDN has been introduced in Japanese, so I think this will be helpful.
https://developer.mozilla.org/ja/docs/Web/JavaScript/Guide/Using_promises

I'm having trouble with navigator.mediaDevices.getUserMedia

I recognized that I wanted to take out the MediaStream that can be retrieved by getUserMedia and use it as a different function.
Would it be possible to solve this problem by calling another function from then?

constrender=(stream)=>{
  const video= document.getElementById("video");
  video.srcObject=stream;
  video.play();
};

navigator.mediaDevices.getUserMedia({video:true, audio:true})
.then(stream=>{
  render(stream);
})
.catch(error=>{
  console.error(error);
});


2022-09-30 21:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.