tezvyn:

Write a TypeScript async/await function that requests webcam access and handles errors

Source: developer.mozilla.orgbeginner

This tests async/await error handling for getUserMedia and stream attachment. A good answer uses try/catch, sets video.srcObject, and branches on NotAllowedError and NotFoundError. A red flag is omitting catch or using src instead of srcObject.

This tests async/await patterns with permission-based media APIs and secure context awareness. A strong answer guards navigator.mediaDevices, awaits getUserMedia with video true inside try/catch, sets video.srcObject, and handles NotAllowedError for user denial, NotFoundError for missing hardware, and AbortError when device access fails. It also notes the promise may never settle if the user ignores the prompt. A red flag is using video.src instead of srcObject, omitting catch, or ignoring HTTPS requirements.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Write a TypeScript async/await function that requests webcam access and handles errors · Tezvyn