HttpGet(url, [headers]) Last updated: 02. Nov 2023

Calls specified web service and expects JSON. Parses JSON to object.

Parameters

Name Type Description
url string URL to call with HTTP GET.
headers (optional) object Name / value object that will be converted to HTTP headers.

Returns

Returns JSON parsed object.

Example

Data

{
"login" : "test",
"password": "test"
}

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
// Basic authentication
var headers = {
    "Authorization" : "BASIC " + docly.base64(login + ":" + password)
};
 
// Call some API
var result = docly.httpGet("https://somewebsite.com/API/Call?id=1", headers);
 
// Handle error 
if(result.DoclyError) docly.assert(result.DoclyError);
 
// Output result
return JSON.stringify(result);

Output

The #JS code above produces the output shown below:
Only works in API functions, no demo.