Sha256: 6769f1ea6693a7b1dba7306453f679fb7a116a51b0db9286964dee6c808efa28
Contents?: true
Size: 700 Bytes
Versions: 5
Compression:
Stored size: 700 Bytes
Contents
import { csrfToken } from "../../lib/request"; function buildForm(url: string, body: Record<string, string>) { const form = document.createElement("form"); form.action = url; form.method = "POST"; form.target = "_blank"; for (const [name, value] of Object.entries(body)) { const input = document.createElement("input"); input.type = "hidden"; input.name = name; input.value = value; form.appendChild(input); } return form; } export function openPreview(url: string, body: Record<string, string>) { const form = buildForm(url, { authenticity_token: csrfToken(), ...body }); document.body.appendChild(form); form.submit(); document.body.removeChild(form); }
Version data entries
5 entries across 5 versions & 1 rubygems