http
http(url: string, options: [HttpRequestOptions](/resources/components/runtimes/types/http-request-options)): [HttpResponse](/resources/components/runtimes/types/http-response) http function allows a Reactor to make external HTTP requests.
Availability
| Discount | Rule | Reactor |
|---|---|---|
| ✓ |
Security
All external requests must be done using HTTPS. It's possible to restrict which hostnames are allowed on a system level by setting the reactors/effects/httpRequest/allowedHosts
Examples
GET request
filtrera
export method(:nothing) => http(
'https://example.com'
{
headers = {
'Authorization' -> 'Bearer `<token>`'
}
}
)POST request
If Content-Type is set to application/json, any non-text value will be converted into JSON automatically.
filtrera
export method(:nothing) => http(
'https://example.com'
{
method = 'POST'
headers = {
'Authorization' -> 'Bearer `<token>`'
'Content-Type' -> 'application/json'
}
body = {
prop1 = 'value'
}
}
)