function apiHandler()

in client/src/main.js [23:51]


function apiHandler(api, params) {

    console.log(`API Handler ${api}`, params);

    params.widget.forEach((val) => {

        let accountId = val.accountId?val.accountId:"" ;
        
        var options = {
            url: params.url+'?role=CloudWatchSnapshotGraphs&accountId='+accountId+ '&widgetDefinition='+encodeURIComponent(JSON.stringify(val.widgetDefinition)),
            headers: {
                    'x-api-key' : params.api_key,
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Accept' : 'image/png'
            }
        };

    	request(options, function (error, response, body) {
      		console.log('error:', error); 
      		console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
      		console.log('body:', body)

            var img = new Buffer(body, 'base64');
      		render(img);

    	});
    });
           
}