이 문서는 https://tiddlywiki.com/languages/ko-KR/에서 티들리위키의 정적 HTML 표현의 일부입니다

WidgetMessage: tm-http-request

2024년 6월 14일 오후 8:47

The tm-http-request message is used to make an HTTP request to a server.

It uses the following properties on the event object:

NameDescription
paramNot used
{any other params}Any other parameters are made available as variables within the context of the widget message. See below.

The following parameters are used:

NameDescription
methodHTTP method (eg "GET", "POST")
bodyString data to be sent with the request
binaryNew in v5.3.1 Set to "yes" to cause the response body to be treated as binary data and returned in base64 format
useDefaultHeadersNew in v5.3.4 Defaults to true. Set to "false" to prevent default headers from being added. This can be helpful when dealing with apis that restrict header fields.
query-*Query string parameters with string values
header-*Headers with string values
password-header-*Headers with values taken from the password store
password-query-*Query string parameters with values taken from the password store
basic-auth-usernameNew in v5.3.4 Optional username for HTTP basic authentication
basic-auth-username-from-storeNew in v5.3.4 Optional username for HTTP basic authentication, specified as the name of the entry in the password store containing the username
basic-auth-passwordNew in v5.3.4 Optional password for HTTP basic authentication
basic-auth-password-from-storeNew in v5.3.4 Optional password for HTTP basic authentication, specified as the name of the entry in the password store containing the password
bearerAuthTokenNew in v5.3.6 Optional plain text token for HTTP bearer authentication
basic-auth-password-from-storeNew in v5.3.6 Optional token for HTTP bearer authentication, specified as the name of the entry in the password store containing the token
var-*Variables to be passed to the completion and progress handlers (without the "var-" prefix)
bind-statusTitle of tiddler to which the status of the request ("pending", "complete", "error") should be bound
bind-progressTitle of tiddler to which the progress of the request (0 to 100) should be bound
oncompletionAction strings to be executed when the request completes
onprogressAction strings to be executed when progress is reported

The following variables are passed to the completion handler:

NameDescription
statusHTTP result status code (see MDN)
statusTextHTTP result status text
errorError string
dataReturned data
headersResponse headers as a JSON object

The following variables are passed to the progress handler:

NameDescription
lengthComputableWhether the progress loaded and total figures are valid - "yes" or "no"
loadedNumber of bytes loaded so far
totalTotal number bytes to be loaded

Note that the state tiddler $:/state/http-requests contains a number representing the number of outstanding HTTP requests in progress.

Examples