The fetch Command


fetch <stringLike> [<object literal>] [ as ( json | text | request ) ]


The fetch command issues a fetch request to the given URL. The URL can either be a naked URL or a string literal.

By default the result will be processed as text, but you can have it processed as JSON, or as a raw request object by adding the as json or as request modifiers.

This command saves the result into the it variable.

This command is asynchronous.


<div _='on click fetch /example
                 put it into my.innerHTML'>
  Get from /example!

<div _='on click fetch /test {method:"POST"} as json 
                 put "$it.result" into my.innerHTML'>
  Post to /example!