For the complete documentation index, see llms.txt. This page is also available as Markdown.

Middleware

Transform FactFinder requests and responses before components receive data.

Documentation

Middleware

Starting with version 1.2.13, FactFinder Web Components supports middleware.

Middleware modules manipulate data exchanged between FactFinder and Web Components. Register modules through Web Components or JavaScript.

FactFinder Web Components approach

Place ff-middleware directly inside ff-communication. It contains all configured modules.

<ff-communication url="..."
                  version="..."
                  api="..."
                  channel="...">
    <ff-middleware></ff-middleware>
</ff-communication>

ff-middleware must be an immediate child of ff-communication. Otherwise, module registration causes an application error.

JavaScript approach

Attach an event handler to ffReady. Register modules with use() in the relevant middleware namespace.

window.addEventListener("ffReady", function (event) {
    const factfinder = event.factfinder;
    factfinder.middleware.response.use(module);
});

This example registers response middleware. It runs after FactFinder responds and before ResultDispatcher notifies its listeners.

Available modules

All modules support Web Components and JavaScript registration. When using Web Components, place every module directly inside ff-middleware.

Response

Response middleware modifies response data. It is available through factfinder.middleware.response. Register modules with factfinder.middleware.response.use().

MultiAttributeParsing

MultiAttributeParsing parses multi-attribute fields into accessible JavaScript objects. FactFinder returns multi-attribute fields as strings:

The module converts that value to:

Use non-empty Mustache list sections to render parsed fields. Mustache supports spaces in property names.

Register MultiAttributeParsing with Web Components:

Or register it with JavaScript:

See the API reference for all configuration options.

ProductTeaserCampaignProcessor

This module inserts teaser feedback text campaigns into searchResult.records. It inserts them at their configured positions.

Each teaser produces an ff-record with an is-teaser attribute. Its inner HTML contains the text configured in FactFinder.

Configure it with Web Components:

Or configure it with JavaScript:

API code

ff-middleware

ff-multi-attribute-parsing

Properties

Properties
Name
Description

src-property (String, required)

Multi-attribute field name returned by FactFinder.

store-in-property (String, required)

Property where the parsed object is stored.

keep-original-in-property (String, optional)

Property where the original unparsed value is stored.

entry-separator (String, default: "ǀ")

Character separating key-value pairs in FactFinder.

key-value-separator (String, default: "=")

Character separating each key from its value.

ff-product-teaser-campaign-processor

This element has no properties.

Last updated

Was this helpful?