Skip to main content

Sends GET and POST requests to an Extbase controller action from your own code, for example from the load callback of an async search.

post() nests data under the Extbase argument namespace of the URL, the tx_{extension}_{plugin}[...] that f:uri.action builds into it, and sends a multipart/form-data body, the shape Extbase's argument mapper reads from an HTML form. The third argument takes fetch options such as { signal }.

Nested objects and arrays are flattened into bracket notation, so an action that takes an object works as it is. null and undefined are skipped, a File or Blob is sent as it is:

A URL without an [action] or [controller] key in its query string, such as a pretty URL built by a route enhancer, has no namespace to read, so data is sent unprefixed. Pass the namespace as prefix, get() takes it too. An empty prefix sends data unprefixed, which makes post() a plain FormData POST for endpoints outside Extbase:

objectName nests the data one level deeper, between the prefix and the keys:

The values.toObject() of a Form carries Extbase's hidden fields (__trustedProperties, __identity) under a key named like the prefix. post() keeps that key below the prefix alone, so this sends the form the way the browser would:

get() appends data as query parameters under the Extbase argument namespace of the URL, flattened like in post(). The URL can be relative, as f:uri.action returns it, or absolute.

A URL from f:uri.action carries a cHash computed from the arguments known when it was built. get() keeps the query of the URL, cHash included, so a parameter it adds fails the check and TYPO3 answers with a 404. Recommended: send the data with post(), since the cHash covers only the query string. To keep get(), exclude the parameter in your settings.php:

The entry is an exact match. Prefix it with ^ to cover nested keys like tx_myextension_citysearch[demand][city].

Reads the namespace that get() and post() use, without sending a request. It returns null for a URL without an [action] or [controller] key in its query string:

get() and post() return the native Response and reject on a network failure or an aborted signal. A non-2xx response resolves normally, so check response.ok.

A 422 response with a JSON object as body, which is what JsonValidationErrorsTrait answers for failed validation, throws an ExtbaseValidationError. Its errors hold the messages by property path and its response is the unread 422 response:

A Form catches that error itself when it is thrown from onSubmit.

An action argument that is a plain PHP class takes the data of extbase.post() without further setup. For a persisted entity (a class extending AbstractEntity, AbstractDomainObject or AbstractValueObject), Extbase only sets the properties that the controller allows:

List the properties by name. allowAllProperties() would let a visitor set every property of the object, also those no field shows.

Sends GET and POST requests to an Extbase controller action from your own code, e.g. from the load callback of an async search. The data is nested under the Extbase argument namespace of the URL, the way f:uri.action builds it.

GETs url with data appended as query parameters under its Extbase argument namespace. The URL's own query, cHash included, is kept - so the new parameters have to be listed in FE.cacheHash.excludedParameters, or TYPO3 rejects the request.

NameDescriptionRequiredDefault
urlstring
The URL of the action, absolute or relative.
Yes
-
dataRecord<string, unknown>
The arguments. Nested objects and arrays are flattened into bracket notation.
No
-
optionsExtbaseRequestInit
More options for fetch, e.g. { signal }, and the prefix and objectName to nest the data under.
No
-

Returns Promise<Response>. The native Response. A non-2xx status resolves normally, check response.ok, except a 422 with a JSON object as body, which throws an ExtbaseValidationError.

POSTs data as multipart/form-data, nested under the URL's Extbase argument namespace. A URL without one gets data unprefixed.

NameDescriptionRequiredDefault
urlstring
The URL of the action.
Yes
-
dataRecord<string, unknown>
The arguments. Nested objects and arrays are flattened into bracket notation, null and undefined are skipped, a File or Blob is sent as it is. The toObject() of the values of a Form works as it is.
No
-
optionsExtbaseRequestInit
More options for fetch, e.g. { signal }, and the prefix and objectName to nest the data under.
No
-

Returns Promise<Response>. The native Response. A non-2xx status resolves normally, check response.ok, except a 422 with a JSON object as body, which throws an ExtbaseValidationError.

Reads the Extbase argument namespace (tx_myextension_eventregistration) of a frontend action URL, from its [controller] or [action] query key. UriBuilder::uriFor() nests those under it, also for a custom pluginNamespace.

NameDescriptionRequiredDefault
urlstring
The URL of the action.
Yes
-

Returns string | null. The namespace, or null for a URL without such a key.