BBLANG

HTTP

bb:http:req(url|options, callback)

url

string (required)

options

map

options : {
method:        // HTTP Method (default: "GET"),
url:           // URL to send request to
headers:       // HTTP Headers,
body:          // Request Body

form:          // Accepts data in map format and adds "Content-type: application/x-www-form-urlencoded" in the header

formData:      // Data to pass for a multipart/form-data request

json:          // sets body to json representation of the value and adds "Content-Type: application/json" to the header

auth:          // Basic Authentication data
oauth:         // Options for OAuth signing (default:  HMAC-SHA1)

encoding:      // encoding to be used on setEncoding header of response data (pass null for Buffer data)
}

sending a json as form

Basic Authentication

HTTP Response

Examples

sending a post request with header fields and body.

bb:http:get(url)

Same asbb:http:req(), but defaults tomethod: "GET".

Examples

bb:http:post(url)

Same asbb:http:req(), but defaults tomethod: "POST".

bb:http:put(url)

Same asbb:http:req(), but defaults tomethod: "PUT".

bb:http:patch(url)

Same asbb:http:req(), but defaults tomethod: "PATCH".

bb:http:delete(url)

Same asbb:http:req(), but defaults tomethod: "DELETE".

bb:http:head(url)

Same asbb:http:req(), but defaults tomethod: "HEAD".

MEMORY

bb:mem:get(key)

Retrieves the string representation of data corresponding to the given key.

Examples

bb:mem:set(key, value)

Creates a new entry in memory corresponding to given key and sets the string representation of the given data as the value, or update the data to the given value if the key is already present.

Examples

bb:mem:del(key)

Deletes the memory entry corresponding to the given key.

Examples

UTILS

bb:log(message1, message2, message3, ...)

Logs outmessage1 message2 message3along with the datetime.

Last updated