title: WidgetMessage: tm-http-request Example - Random Dog tags: $:/tags/Macro $:/tags/Global \procedure download-dog(url) \procedure completion-download-dog() \import [subfilter{$:/core/config/GlobalImportFilter}] <$action-log msg="In completion-download-dog"/> <$action-log/> <$list filter="[compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore"> <$action-createtiddler $basetitle=`$:/RandomDog/$(title)$` text=<> tags="$:/tags/RandomDog" type={{{ [jsonget[content-type]] }}} credits="https://random.dog/" > <$action-log msg="Created tiddler" title=<>/> \end completion-download-dog <$action-sendmessage $message="tm-http-request" url=<> method="GET" binary="yes" oncompletion=<> var-title=<> /> \end download-dog \procedure get-random-dog() \procedure completion-get-json() \import [subfilter{$:/core/config/GlobalImportFilter}] <$action-log msg="In completion-get-json"/> <$action-log/> <$list filter="[compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore"> <$macrocall $name="download-dog" url={{{ [jsonget[url]] }}}/> \end completion-get-json <$action-sendmessage $message="tm-http-request" url="https://random.dog/woof.json" method="GET" oncompletion=<> /> \end get-random-dog !! Random Dogs This demo uses the API of the website https://random.dog/ to import a random dog image or video. //Note that the images and videos can be quite large, so this demo is not recommended to be used over mobile data connections.// <$button actions=<>> Import a random dog image or video <$list filter="[tag[$:/tags/RandomDog]limit[1]]" variable="ignore"> !! Imported Tiddlers <$button> <$action-deletetiddler $filter="[tag[$:/tags/RandomDog]]"/> Delete all imported random dogs Export all imported random dogs: <$macrocall $name="exportButton" exportFilter="[tag[$:/tags/RandomDog]]" lingoBase="$:/language/Buttons/ExportTiddlers/"/>
    <$list filter="[tag[$:/tags/RandomDog]!sort[modified]]">
  1. <$link> <$text text=<>/>
    <$transclude $tiddler=<>/>