import {VBase} from './base'; import appConfig from '../../config'; import {expandParams} from './action_parameter'; import {encode} from './encode'; import {getEventTarget} from '../get_event_target'; import {buildFormData} from '../../utils/form-data' // Replaces a given element with the contents of the call to the url. // parameters are appended. export class VPosts extends VBase { constructor(options, url, params, method, event, root) { super(options, root); this.url = url; this.params = params; this.method = method; this.event = event; this.headers = options.headers; } call(results, eventParams) { this.clearErrors(); let method = this.method; const ev = new CustomEvent('V:postStarted', { bubbles: true, cancelable: false, detail: this, composed: true, }); this.dispatchLifecycleEvent(this.event, ev); // Manually build the FormData. // Passing in a