Logo Text Blaze

  • Docs
  • Community
  • Documentation

    No search results

    Text Blaze

    Loading...

    Data Blaze

    Loading...

    Community Forums

    Loading...
Add to Chrome –  It's Free! Go to Dashboard ›
Commands

{urlload}

Summary: Loads data from a URL into the snippet
Sample Usage
Load data from (simulated) API: {urlload: https://blaze.today/api/temperature; done=(res) -> ["temperature": catch(fromJSON(res).temperature, "???")]}

The temperature is currently {=temperature}°
_

Settings


Setting NameTypeDescription
startfunctionFunction called when loading is started. Returns a keyed list of form values.
donefunctionFunction called with the data loaded from the url. Returns a keyed list of form values.
General URL Settings
_urlThe URL to request. Fox example, https://example.com/page
methodGET/POST/...The HTTP method used to make the request. Defaults to GET.
bodytextThe body of the request.
headersKey/Value ListA list of headers. For example, Content-Type=text/json,Authorization=Basic 12345
General Command Settings
trimyes/no/left/rightIf yes whitespace is removed before and after the command. If left, only whitespace to the left is removed. If right, only whitespace to the right is removed.
urlload is a Connected Snippet command. Connected Snippets are advanced commands currently in Beta. They may change in the future.

The urlload command allows you to load data into your snippet from an API or external source.

The command's first positional setting is the URL that you want to load data from.

If the URL contains characters that have special significance in Text Blaze commands, they must be escaped with backslashes. Notably {, }, \ and ; should be escaped by placing a single \ before them.

For example, { would become \{ and \ would become \\.

See the Escaping Special Characters section of the Formula Blaze Reference page to learn more.

The start and done settings

Both the start and done settings are functions. This gives you great flexibility in processing the results of a data loading operation.

The start function is called when the loading request is initially started. It isn't passed any arguments.

The done function is called when loading completes. It returns the body of the response as its first argument and the HTTP status code as its second argument.

Both the start and done settings should return a keyed list.

The keys in this list represent variables. The variables are set to the corresponding values in the list when the function is applied. The example at the top of the page shows how we can use this to set a temperature value when the results from the loading request are returned.

The keyed list can have a single key or multiple keys. For example, ["x": 10, "y": 12] would update the variable values of both x (becoming 10) and y (becoming 12).

One useful way to use the start setting is to display a loading indicator. You can then clear it when the done function is invoked. For instance, your start function might return ["loading": yes] and your done function could return ["loading": no, ...]. You could then use an {if} command to conditionally show a loading indicator. The following example illustrates this approach.

Loading Indicator

Enter a URL path to load: {formmenu: name=path; default=api/temperature; docs/; commands/}

{urlload: https://blaze.today/{=path}; start=()->["loading": yes]; done=(contents, status)->["loading": no, "contents": contents, "status": status]}

{if: loading} Loading URL... {else} Request Status: {=status} URL Contents: {=contents} {endif}

_

General URL Settings

Besides the start and done settings you also get access to a few more settings that allow you to get more precise with how you request data.

Those general URL settings are method, body, and headers.

Doing a deep dive into these settings is out of scope for this command's documentation and assumes knowledge of how HTTP works.

Handling errors

Remote data loading may fail for a variety of reasons (the server is down or inaccessible, incorrect URL, etc...). You should make sure to handle errors gracefully by checking the HTTP status or using the catch function.

See also the {urlsend} command for sending data to a server on snippet insertion.

Sharing connected snippets with others

When sharing snippets with others, snippets containing the urlload command may only be shared with members of your Text Blaze Business organization.

  • Guides
    • Quick Start
    • Sharing Snippet Folders
    • Dynamic Commands
    • Date and Time
    • Autopilot
    • Forms
    • Formulas
    • Rules & Validation
    • Tidying Whitespace
    • Lists
    • Teams and Organizations
  • Tutorial Videos
  • Academy
    • Intro to commands
  • Showcase
  • Frequently Asked Questions
  • Formula Reference
  • Dynamic Commands
    • Using Dynamic Commands
    • {=} (Formula Command)
    • {click}
    • {clipboard}
    • {cursor}
    • {error}
    • {formdate}
    • {formmenu}
    • {formparagraph}
    • {formtext}
    • {formtoggle}
    • {if}
    • {import}
    • {key}
    • {link}
    • {note}
    • {repeat}
    • {site}
    • {snippet}
    • {time}
    • {user}
    • {wait}
  • Connected Snippets
    • Connected Snippets Overview
    • {image}
    • {urlload}
    • {urlsend}
    • {dbselect}
    • {dbinsert}
    • {dbupdate}
    • {dbdelete}
  • Command Packs
    • Capitalize
    • Gmail
    • LinkedIn
    • Randomize

About

Plans and Pricing
Sharing Snippets
Text Blaze for Business
Forms
Autopilot
Dynamic Commands
Command Packs
Text Blaze for Windows

Support

Get Started with Text Blaze
Contact Us
Documentation
Community Forum
Blog

Solution for

Teams
Customer Support
Recruiters
Education
Healthcare
Sales
Property Managers

Other

Privacy Policy
Terms of Service
Open Source Licenses
Affiliate
© 2023 Blaze Today Inc