powered by

$processor$: http

This processor is used to initialise some FTD variable with content of JSON fetched from HTTP.
⚠️
Static Vs Dynamic
The http request is made on build time if you are using fastn in static site mode, and instead if you are using server mode then this processor makes http request on every page load.
Consider this data type:
-- record repo:
string full_name:
string description:
string html_url:
integer stargazers_count:
integer watchers_count:

-- record result:
integer total_count: 0
repo list items:

We have two records: repo, and result. We also have a variable of type result.

Lets initialise this variable with result of fetching the top repositories from Github:
-- import: fastn/processor as pr

-- result r:
$processor$: pr.http
url: https://api.github.com/search/repositories
sort: stars
order: desc
q: language:python

url: string

This is the URL where we would be fetching the JSON from. It is mandatory.

method: optional string

This is the method of the http request. It’s an optional field with get as default value. Currently only two methods are supported: get and post

Key: Value pairs

Each key value pair is passed added to the URL as query params, if http request method is get. Otherwise, the pair is passed as the request body.
-- string amit-bio:

I am Amit.

-- person amit:
$processor$: pr.http
method: post
name: "Amit"
age: 33
bio: $amit-bio
For post method, the above code would convert into the following request body:
{
    "name": "Amit",
    "age": 33,
    "bio": "I am Amit."
}

Currently, there is no way to specify the type of the body parameters, so you need to use " to pass the value as a string type, or you can define any variable and pass it as a reference since the type of the variable is known.

The response of the JSON must match with type of the variable where we are storing the result, here it is r of type record result defined above.

Support fastn!

Enjoying fastn? Please consider giving us a star ⭐️ on GitHub to show your support!

Getting Help

Have a question or need help?

Visit our GitHub Q&A discussion to get answers and subscribe to it to stay tuned.

Join our Discord channel and share your thoughts, suggestion, question etc.

Connect with our community!

Found an issue?

If you find some issue, please visit our GitHub issues to tell us about it.

Join us

We welcome you to join our Discord community today.

We are trying to create the language for human beings and we do not believe it would be possible without your support. We would love to hear from you.

$processor$: http

This processor is used to initialise some FTD variable with content of JSON fetched from HTTP.
⚠️
Static Vs Dynamic
The http request is made on build time if you are using fastn in static site mode, and instead if you are using server mode then this processor makes http request on every page load.
Consider this data type:
-- record repo:
string full_name:
string description:
string html_url:
integer stargazers_count:
integer watchers_count:

-- record result:
integer total_count: 0
repo list items:

We have two records: repo, and result. We also have a variable of type result.

Lets initialise this variable with result of fetching the top repositories from Github:
-- import: fastn/processor as pr

-- result r:
$processor$: pr.http
url: https://api.github.com/search/repositories
sort: stars
order: desc
q: language:python

url: string

This is the URL where we would be fetching the JSON from. It is mandatory.

method: optional string

This is the method of the http request. It’s an optional field with get as default value. Currently only two methods are supported: get and post

Key: Value pairs

Each key value pair is passed added to the URL as query params, if http request method is get. Otherwise, the pair is passed as the request body.
-- string amit-bio:

I am Amit.

-- person amit:
$processor$: pr.http
method: post
name: "Amit"
age: 33
bio: $amit-bio
For post method, the above code would convert into the following request body:
{
    "name": "Amit",
    "age": 33,
    "bio": "I am Amit."
}

Currently, there is no way to specify the type of the body parameters, so you need to use " to pass the value as a string type, or you can define any variable and pass it as a reference since the type of the variable is known.

The response of the JSON must match with type of the variable where we are storing the result, here it is r of type record result defined above.

Support fastn!

Enjoying fastn? Please consider giving us a star ⭐️ on GitHub to show your support!

Getting Help

Have a question or need help?

Visit our GitHub Q&A discussion to get answers and subscribe to it to stay tuned.

Join our Discord channel and share your thoughts, suggestion, question etc.

Connect with our community!

Found an issue?

If you find some issue, please visit our GitHub issues to tell us about it.

Join us

We welcome you to join our Discord community today.

We are trying to create the language for human beings and we do not believe it would be possible without your support. We would love to hear from you.