fastn-stack / fastn

🚧 (Alpha stage software) fastn - better way to build websites 🚧
https://fastn.com
GNU Affero General Public License v3.0
466 stars 36 forks source link

fix(ftd.http): replicate error response behaviour for data response #1822

Closed siddhantk232 closed 5 months ago

siddhantk232 commented 5 months ago

For the errors response from server, ftd.http correctly prepends defined variables with the fastn-module name provided through ftd.http-options.

The same thing is not done for data response. This PR fixes this.

E.g.

-- optional string $name:

-- ftd.text: $name
if: { name }

-- ftd.text: test
$on-click$: send-req()

-- ftd.http-options opts:
method: GET
fastn-module: fastn-test-multiauth/

-- void send-req():
ftd.http-options opts: $opts

ftd.http(
    "http://localhost:3000/test.json",
    opts
)

The response from the server (http://localhost:3000/test.json):

{
    "data": {
        "name": "spiderman"
    }
}

The ftd.text shows "spiderman" with this change.