Skip to content

Brain ​

A client of the Brain (the platform's central application), for pages that are not served by a site.

Quick start ​

ts
const brain = new window.Portal.brain.Client({ subdomain: 'www' });
const member = await brain.getMember('MEMBER_REF');
console.log(member);

API reference ​

brain ​

A client of the Brain (the platform's central application).

getMember() ​

Fetches the member payload for the given reference number.

ts
const result = await brain.getMember(referenceNum);

Parameters

NameTypeRequiredDescription
referenceNumstringYesThe record's reference number.

Returns

Resolves with Record<string, unknown> \| null.

isDev() ​

Returns true when the configured base URL points to the development brain host.

ts
const ok = brain.isDev();

Returns

Returns a boolean.

isProd() ​

Returns true when the configured base URL points to a production brain host.

ts
const ok = brain.isProd();

Returns

Returns a boolean.

window.Portal.brain ​

Portal.brain — talk to the Brain from a page that is not served by a site.

Client ​

Constructs a BrainClient that can query the external brain API.

new ​
ts
const client = new window.Portal.brain.Client(opts);

Parameters

NameTypeRequiredDescription
optsPortalBrainClientOptionsNoOptions of new Portal.brain.Client().

Returns

Returns a PortalBrainClient: A client of the Brain (the platform's central application).

getBaseUrl() ​

The Brain's base address: https://www15.appfactory.studio for 'www15', else https://www.appfactory.studio.

ts
const value = window.Portal.brain.Client.getBaseUrl(subdomain);

Parameters

NameTypeRequiredDescription
subdomain'www15' | 'www'NoThe Brain application subdomain.

Returns

Returns a string.

Types ​

PortalBrainClientOptions ​

Options of new Portal.brain.Client().

NameTypeRequiredDescription
subdomain'www15' | 'www'NoThe brain application subdomain. Use "www15" for development and "www" for production.
baseUrlstringNoOptional override for the brain application base URL.