Submits the given action by making an HTTP request according to action's
method and href.
If fields are present in action, they are validated via
options.validator. A ValidationError is thrown when
options.validator returns a NegativeValidationResult. If
options.validator is not provided, then validation automatically passes.
If validation passes, the fields are then serialized according to
options.serializer, which receives action's type and fields. If
options.serializer is not provided, the defaultSerializer is
used. If action.method is 'GET' or 'DELETE', the serialized content is
placed in the query string. Otherwise, the content is placed in the request
body.
awaitsubmit(action, { validator: (fields) => { // ensure each field has a non-nullish value if (fields.every((field) =>field.value != null)) returnnewPositiveValidationResult(); else returnnewNegativeValidationResult(); },
serializer: (type, fields) => { if (type === 'text/xml') return { content:// serialize fields to XML however you like... }; else // rely on default serializer for any other type returndefaultSerializer(type, field); } })
Returns
a Promise that fulfills with an HTTP Response object
Submits the given
actionby making an HTTP request according toaction'smethodandhref.If
fieldsare present inaction, they are validated viaoptions.validator. AValidationErroris thrown whenoptions.validatorreturns aNegativeValidationResult. Ifoptions.validatoris not provided, then validation automatically passes.If validation passes, the
fieldsare then serialized according tooptions.serializer, which receivesaction'stypeandfields. Ifoptions.serializeris not provided, thedefaultSerializeris used. Ifaction.methodis'GET'or'DELETE', the serialized content is placed in the query string. Otherwise, the content is placed in the request body.Example
Returns
a
Promisethat fulfills with an HTTPResponseobjectThrows
a
ValidationErrorwhenoptions.validatorreturns aNegativeValidationResult