Skip to main content

Bridge.Feed

.feeds

Object of available feed data for the current presentation.

Example response:

{
// deck key
"awesome": {
// each feed as defined in the project file
"product_prices": {
"premiere_product": 1000,
"standard_product": 300
},
"factsheet_stats": {
"monthly_users": 1000,
"monthly_visits": 2300
},
"competitors": [
{
"name": "Other company",
"monthly_users": 500
},
{
"name": "Small company",
"monthly_users": 100
}
]
}
}

.get(key)

Fetch the feed object with the name key. This should match the name given to it in the project file. The feed data is cached on-device before the presentation begins, so the data isn't live, but it's recent.

const one = Bridge.Feed.get("data-feed-one");

.getDebugInfo()

Fetch the feed debug information. This function won't take in any keys, but will always use the current deck key for its data. In particular, you can see the feed URL which was used after template variables from your context were applied.

This is useful for figuring out why or if some queries are failing.

const debug = Bridge.Feed.getDebugInfo();

Example response:

{
"products": {
"upstream_url": "https://staging-coolcompany.livepreso.com/api/cool-product/?account_id=",
"upstream_status": 401,
"upstream_reason": null,
"upstream_error": "Product not found on external CRM...",
"upstream_size_kb": null,
"upstream_duration_ms": 17,
"failure_reason": "Invalid response code: 401. Must be {200}."
},
"roadmap": {
"upstream_url": "https://staging-coolcompany.livepreso.com/api/cool-roadmap/?per_page=100",
"upstream_status": 200,
"upstream_reason": null,
"upstream_error": null,
"upstream_size_kb": 1.2,
"upstream_duration_ms": 39,
"failure_reason": null
},
"competitor-products": {
"upstream_url": "https://staging-coolcompany.livepreso.com/api/cool-competitor-products/?per_page=100",
"upstream_status": 200,
"upstream_error": null,
"upstream_reason": null,
"upstream_size_kb": 21.9,
"upstream_duration_ms": 33,
"failure_reason": null
},
}

.match(selector, fallback)

Look inside the feed data and pull out values matching selector. If no value, or multiple values, are found, then fallback is returned instead. Use this when you expect to get a single value from the feed.

See jsonselect for the documentation on how these selectors work.

const samwise_info = Bridge.Feed.get("samwise");
const name = samwise_info.match(".name", "Unknown Name");

.match_many(selector, fallback)

Look inside the feed data and pull out values matching selector. If no values are found, then fallback is returned instead. Use this when you expect to get multiple values from the feed.

const samwise_info = Bridge.Feed.get("samwise");
const sams_friends = samwise_info.match_many(".friend .name", []);

.get(key).raw()

Fetch the feed object with the name key and returns its contents as-is without need for a fallback.

const samwise_info = Bridge.Feed.get("samwise").raw();
warning

As no default is passed through, be extra careful to add validation and tests to the data you receive. Otherwise if invalid data is uploaded, you may find yourself with broken content in the wild.