2 ms·
You can expose your business logic as an API endpoint and have your single-page app make a request to it. For example, say you have a bunch of invoices that you
by Kpourdeilami 9y ago
You can expose your business logic as an API endpoint and have your single-page app make a request to it. For example, say you have a bunch of invoices that you can access by making a GET request to /invoices/
```
{
"count": 1,
"results": {...}
}
```
Then if you want to perform an action on a particular invoice, you can access it using the /invoices/:invoice_id/action endpoint. For example, let's say you want to pay the invoice with id=1, then all you have to do is make a POST request to /invoices/1/pay/
and if you want to pass variables to your action, you can do it through the body of the request. For example, if you want to pay your invoice with a card on the account with id=4, all you have to do would be to make a POST request to /invoices/1/pay/ with the following body:
```
{
"card_id": 4
}
```