Nova · Endpoints
One call after another
A URL and a function in the same action. onSuccess of the first call makes the second, which by then finds the first one’s answer in the data. To the steps a call is a call: where it goes is the endpoint’s business.
{
id: 'endpoint-chain',
data: { member: { name: '', seats: [] }, price: { total: 0 } },
layout: {
component: 'Stack',
children: [
{
if: '$.member.name',
then: {
component: 'Text',
children: '{{$.member.name}} owes {{$.price.total}}.',
},
},
{
component: 'Button',
ref: 'load',
children: 'Work out what is owed',
},
],
},
endpoints: {
member: {
url: '/examples/endpoint-chain/members/m1',
method: 'GET',
target: 'member',
},
price: { fn: 'endpoint-chain.price', target: 'price' },
},
triggers: [
{
event: 'ui:click',
ref: 'load',
do: [{ call: 'member', onSuccess: [{ call: 'price' }] }],
},
],
}{
endpoint-chain.price: { total: 76 },
GET /examples/endpoint-chain/members/m1: {
status: 200,
body: { name: 'Ada', seats: ['C4', 'C5'] },
},
}press load
[
{
method: 'GET',
url: '/examples/endpoint-chain/members/m1',
},
]{
member: { name: 'Ada', seats: ['C4', 'C5'] },
price: { total: 76 },
}Ada owes 76. Work out what is owed
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.