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

feat: add GET support in ftd.http #1813

Closed siddhantk232 closed 5 months ago

siddhantk232 commented 5 months ago

Add support for sending GET requests in ftd.http. Params are transformed into query string or request body depending upon the type of request.

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

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

ftd.http(
    "https://jsonplaceholder.typicode.com/comments",
    opts,
    ("postId", 1)
)

the above snippet will send request to https://jsonplaceholder.typicode.com/comments?postId=1 with the given options.

-- ftd.http-options opts:
redirect: follow
method: POST ;; ONLY THIS IS CHANGED FROM THE ABOVE SNIPPET
fastn-module: test-multiauth

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

ftd.http(
    "https://jsonplaceholder.typicode.com/comments",
    opts,
    ("postId", 1)
)

the above snippet will send request to https://jsonplaceholder.typicode.com/comments with request body as {"postId": 1}.