loading... Pacem JS

PacemFetchElement is the predefined custom element that handles the asynchronous http communication with the server side of your application.

It basically wraps the fetch API.

Requests

PacemFetchElement sends a request as soon as autofetch is true (default) and:

Then, it will wait for one of the following properties to change in order to trigger a new request:

Calling the method fetch() always triggers a new request as well (if not disabled, of course).

While a response is awaited, the fetching flag is set to true (and emits relevant propertychange event).

A couple of tricky flags

If autofetch is set to false then you manually need to call fetch() method.

Since parameters and headers are complex objects, they can bring the exact same values but trigger the fetch anyway if the very underlying instance reference has changed (default behavior).
If you're cheap on networking then set diffByValues to true and both parameters and headers will be diffed only by their values and not by their instance tokens.

Responses

When a response is obtained, the fetching flag is set to false (and emits...).

Once the response has been successfully returned:

Once the response body has been parsed into the expected entity:

Results type hints can be given to the fetcher by setting the as property (above).

If anything went wrong: