import { Controller } from '@hotwired/stimulus'; export default class extends Controller { static values = { commands: String, } remoteControl() { // cf const baseurl = 'http://localhost:8111'; const _this = this, commands = JSON.parse(this.commandsValue); for (var command in commands) { var url = baseurl + '/' + command, params = new URLSearchParams(); for (var name in commands[command]) { params.append(name, commands[command][name]); } if (Array.from(params.length > 0)) { url += '?' + params.toString(); } fetch(url) .then(function (response) { return response.text(); }) .then(function (text) { }); } } }