Example using Node.js (JavaScript)

THIS EXAMPLE IS PROVIDED „AS IS“, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE EXAMPLE OR THE USE OR OTHER DEALINGS IN THE EXAMPLE.

Request Staff List

var http = require('http');
 
export.get_list(resolve, reject) {
    var options = {
        hostname: '...',
        port: 80,
        path: '/ustrich/rest/staff/all',
        method: 'GET',
        headers: {
          'Accept': 'application/json'
        },
        auth: 'RESTUSER:RESTPASSWORD'
    };
 
    var req = http.request(options, function (res) {
        //Get response
        res.setEncoding('utf8');
        var data = ''
        res.on('data', function (chunk) {
            data += chunk;
        });
 
        res.on('end', function () {
            var jsonData = JSON.parse(data);
            resolve(jsonData);
        });
    });
    req.on('error', reject);
    req.end();
}