Nova · Endpoints
HTTP endpoint
An endpoint that names a URL. The address is a template over the action’s data, and onSuccess runs once the answer has been written to target.
{
id: 'http-endpoint',
data: {
id: 'm1',
state: 'not asked',
member: { name: '', pass: '' },
},
layout: {
component: 'Stack',
children: [
{ component: 'Text', children: 'State: {{$.state}}' },
{
if: '$.member.name',
then: {
component: 'Text',
children: '{{$.member.name}} has a {{$.member.pass}} pass.',
},
},
{
component: 'Button',
ref: 'load',
children: 'Look the member up',
},
],
},
endpoints: {
member: {
url: '/examples/http-endpoint/members/{{$.id}}',
method: 'GET',
target: 'member',
},
},
triggers: [
{
event: 'ui:click',
ref: 'load',
do: [
{ set: 'state', value: 'asking' },
{
call: 'member',
onSuccess: [{ set: 'state', value: 'answered' }],
},
],
},
],
}State: not asked
{
GET /examples/http-endpoint/members/m1: { status: 200, body: { name: 'Ada', pass: 'season' } },
}press load
[
{
method: 'GET',
url: '/examples/http-endpoint/members/m1',
},
]{
id: 'm1',
state: 'answered',
member: { name: 'Ada', pass: 'season' },
}State: answered Ada has a season pass. Look the member up
Left: the action as the package ships it. Right: the same action running in this page, rendered with this site’s components. Below: the action run as the example specifies, on the installed package.