Skip to main content

executeTemplate

Stentor API Reference


Stentor API Reference / stentor-response/src / executeTemplate

Function: executeTemplate()

executeTemplate\<T>(templatedResponse): Promise\<ResponseOutput>

Defined in: packages/stentor-response/src/TemplatedResponseOutput.ts:38

Convert the template to an actual response.

Throws an error if it can't find a match in the provided data so wrap this in a try { } catch { } and plan on having a fallback response.

This function leverages _.template, see https://lodash.com/docs/#template

Type Parameters​

T​

T extends object

Parameters​

templatedResponse​

TemplatedResponseOutput\<T>

Returns​

Promise\<ResponseOutput>