function makeCall(host, port, method, path, headers, data) {
	var options = {};
	options.host = host;
	options.port = port;
	options.method = method;
	options.path = path;
	options.headers = headers;

	return new Promise((resolve, reject) => {
		var req = https.request(options, function (res) {
			var body = "";
			console.log("statusCode: ", res.statusCode);
			res.on('data', function (data) {
				body += data;
			});
			res.on('end', function () {
				//here we have the full response, html or json object
				if (Utils.IsJson(body)) {
					result = JSON.parse(body);
					result["status"] = res.statusCode;
					resolve(result);
				}
				else {
					if (body) {
						resolve(body);
					}
					else {
						resolve('Ok');
					}
				}
			});
			res.on('error', function (e) {
				console.log("Got error: " + e.message);
			});
		});
		req.on('error', (error) => {
			console.log(error);
			reject(error);
		});

		if (data) {
			req.write(data);
		}
		else {
			req.write("");
		}
		req.end();
	})
}
//Boilerplate code to make the API calls (it just works, I hardly know how. Ask Bundy)
Boilerplate code to make the API calls (it just works, I hardly know how. Ask Bundy)
Boilerplate code to make the API calls ( it just works I hardly know how . Ask Bundy )
function makeCall(host, port, method, path, headers, data) {
	var options = {};
	options.host = host;
	options.port = port;
	options.method = method;
	options.path = path;
	options.headers = headers;
	return new Promise((resolve, reject) => {
		var req = https.request(options, function (res) {
			var body = "";
			console.log("statusCode: ", res.statusCode);
			res.on('data', function (data) {
				body += data;
			});
			res.on('end', function () {
				if (Utils.IsJson(body)) {
					result = JSON.parse(body);
					result["status"] = res.statusCode;
					resolve(result);
				}
				else {
					if (body) {
						resolve(body);
					}
					else {
						resolve('Ok');
					}
				}
			});
			res.on('error', function (e) {
				console.log("Got error: " + e.message);
			});
		});
		req.on('error', (error) => {
			console.log(error);
			reject(error);
		});
		if (data) {
			req.write(data);
		}
		else {
			req.write("");
		}
		req.end();
	})
}
function makeCall ( host , port , method , path , headers , data ) { var options = { } ; options . host = host ; options . port = port ; options . method = method ; options . path = path ; options . headers = headers ; return new Promise ( ( resolve , reject ) => { var req = https . request ( options , function ( res ) { var body = "" ; console . log ( "statusCode: " , res . statusCode ) ; res . on ( 'data' , function ( data ) { body += data ; } ) ; res . on ( 'end' , function ( ) { if ( Utils . IsJson ( body ) ) { result = JSON . parse ( body ) ; result [ "status" ] = res . statusCode ; resolve ( result ) ; } else { if ( body ) { resolve ( body ) ; } else { resolve ( 'Ok' ) ; } } } ) ; res . on ( 'error' , function ( e ) { console . log ( "Got error: " + e . message ) ; } ) ; } ) ; req . on ( 'error' , ( error ) => { console . log ( error ) ; reject ( error ) ; } ) ; if ( data ) { req . write ( data ) ; } else { req . write ( "" ) ; } req . end ( ) ; } ) }
Boilerplate code to make the API calls (it just works, I hardly know how.
Boilerplate code to make the API calls ( it just works I hardly know how .
//here we have the full response, html or json object