UNPKG

spectatr-player-sdk

Version:

A custom video player built with Stencil with Shaka Player integration

65 lines (64 loc) 2.34 kB
import { fetchVideoSrc } from "./videoService"; export async function submitQuizAnswer(component, optionsIds) { try { const response = await fetch(`${component.baseUrl}/sp-onboarding/quiz/submit-answer`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': 'bak8zb8uwimo4pjdmyu3-basluiwthvn3u7qznfgy-2thtwws1764g3706xsoo' }, body: JSON.stringify({ quizOptionIds: optionsIds, userId: component.userId, }), }); fetchVideoSrc(component); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); if (!data.success) { console.error(data.message || 'Failed to submit answer'); component.videoError.emit('Failed to submit quiz answer'); return false; } return true; } catch (error) { component.videoError.emit('Error submitting quiz answer'); console.error('Error submitting quiz answer:', error); return false; } } export async function submitPollAnswer(component, optionsIds) { try { const response = await fetch(`${component.baseUrl}/sp-onboarding/polls/submit-answer`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': 'bak8zb8uwimo4pjdmyu3-basluiwthvn3u7qznfgy-2thtwws1764g3706xsoo' }, body: JSON.stringify({ pollOptionIds: optionsIds, userId: component.userId, }), }); fetchVideoSrc(component); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); if (!data.success) { console.error(data.message || 'Failed to submit answer'); component.videoError.emit('Failed to submit answer'); return false; } return true; } catch (error) { console.error('Error submitting quiz answer:', error); component.videoError.emit('Error submitting quiz answer'); return false; } } //# sourceMappingURL=quizService.js.map