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
action
by making an HTTP request according toaction
'smethod
andhref
.If
fields
are present inaction
, they are validated viaoptions.validator
. AValidationError
is thrown whenoptions.validator
returns aNegativeValidationResult
. Ifoptions.validator
is not provided, then validation automatically passes.If validation passes, the
fields
are then serialized according tooptions.serializer
, which receivesaction
'stype
andfields
. Ifoptions.serializer
is not provided, thedefaultSerializer
is used. Ifaction.method
is'GET'
or'DELETE'
, the serialized content is placed in the query string. Otherwise, the content is placed in the request body.Example
Returns
a
Promise
that fulfills with an HTTPResponse
objectThrows
a
ValidationError
whenoptions.validator
returns aNegativeValidationResult