HTTP with Callback
Using HTTP with Fallback Commands¶
TBL allows you to define success and error fallback commands when making HTTP requests.
These commands are executed automatically based on the result of the request.
If the error command is missing, the success command will run instead.
This makes HTTP workflows simple, safe, and predictable.
Basic HTTP Request with Fallback Commands¶
You can attach success and error commands directly to an HTTP request.
Example:
HTTP.get({
url: "https://jsonplaceholder.typicode.com/todos/1",
success: "onSuccess",
error: "onError",
tbl_options: { key: value }
})
tbl_options¶
tbl_optionsis optional- Used to pass custom data to the next command
- Available directly as
tbl_optionsin the success or error command
Example access:
tbl_options.key
How Command Execution Works¶
- If the HTTP request succeeds:
- The
successcommand is executed optionscontains the HTTP response- If the HTTP request fails:
- The
errorcommand is executed optionscontains the HTTP error- If the
errorcommand is not defined: - The
successcommand will be executed instead
Note
The error command runs only on real HTTP failures
such as invalid URLs, network errors, or server errors (e.g. 500).
Example Success Command¶
The success command receives HTTP response data.
Example:
On success, the following variables are available:http_responseresponsecontent(raw response body string)headerscookies
Example Error Command¶
The error command receives HTTP error details.
Example:
On error, the following are available:erroroptions(error-related response data)tbl_options(if provided)
Available Response Data¶
On successful requests, detailed response information is available.
See full documentation here: HTTP Response
Important Notes¶
Tip
Use fallback commands to keep HTTP logic separate from message logic.
Warning
HTTP fallback commands do not catch TBL runtime errors. Those must be handled using the ! command.
This approach makes external API integration clean, modular, and easy to debug.