Call hateoas actions/links in action of form with method post

Viewed 174

We are using hateoas to call backend our links. Our HateoasWrapper looks like this (copied out from browser console):

{
    $actions: [
        {
            $call: function ()
            action: "load"
            href: "http://myApi"
            method: "POST"
            rel: "parent"
        }
    ],
    $load: function (),
    Links: [
        {
            ActionValue: "load"
            Href: "http://myApi"
            Methid: "POST"
            Reld: "parent"
        }
    ]
}

So we can call simply our links like this: myObject.$load() (it calls the href from load). This works fine.

Now I try to call the $load() in the action of a form element. For this I put the call in the action and fire it with a submit like this:

<form action="ctrl.myObject.$load()" method="post" target="_blank">
    <input type="submit">
</form>

This doesnt work. It opens a new tab, but with this error: Cannot post/ctrl.myObject.$load()

When I put the href hardcoded into the action, it works (new tab with correct data):

<form action="http://myApi" method="post" target="_blank">
    <input type="submit">
</form>

Is it possible to call an hateoas action in a form like my solution?

1 Answers
Related