Instance
An object returned from the template function that contains data from the responses to requests.
Property | Type | Description |
---|---|---|
response | undefined | Element | null | Compiled element from template |
status | HMPLRequestStatus | The status of the response to the request. If there are several requests in the template, this property is not included in the object |
requests | HMPLRequest[] | Contains information for each request in the template. If the template contains only one request, this property is not included in the object |
const instance = templateFn();console.log(instance);
{ status: 200, response: div }
response
Section titled “response”The value is the Element
compiled from the template. If the template does not have a container tag, the response comes as a template
tag with HTML from the server.
const templateFn = compile(`<div>{{#r src="/test"}}{{/r}}</div>`);const instance = templateFn();console.log(instance);
<div> <span>My component</span></div>
const templateFn = compile(`{{#r src="/test"}}{{/r}}`);const instance = templateFn();console.log(instance);
<template> <span>My component</span></template>
status
Section titled “status”Contains all HTTP request codes, as well as states such as "pending"
and "rejected"
.
const instance = templateFn();console.log(instance.status);
200
requests
Section titled “requests”Contains an array of information objects about each request in the template.
const templateFn = compile( `<div>{{#r src="/test1"}}{{/r}}{{#r src="/test2"}}{{/r}}</div>`);const instance = templateFn();console.log(instance);
{ response: div, requests: [ { status: 200, response: b }, { status: 200, response: [a, div] } ]}