import { Controller } from '@hotwired/stimulus'; /* * The following line makes this controller "lazy": it won't be downloaded until needed * See https://github.com/symfony/stimulus-bridge#lazy-controllers */ /* stimulusFetch: 'lazy' */ export default class extends Controller { static values = { url: String, title: String, filename: String, mediaType: String, imdbId: String, episodeId: String } download() { fetch('/api/download', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, body: JSON.stringify({ url: this.urlValue, title: this.element.dataset['title'], filename: this.filenameValue, mediaType: this.mediaTypeValue, imdbId: this.imdbIdValue, episodeId: this.episodeIdValue }) }) .then(res => res.json()) .then(json => { console.log(json) }) } }