/**
 * Created by rockyl on 2019-11-16.
 */

const url = engine.findVariable('url', args, props);
const type = engine.findVariable('type', args, props);
const params = engine.findVariable('params', args, props);
const headers = engine.findVariable('headers', args, props);

if (!url) {
	console.log('url is empty');
	next('exception', 'url is empty');
} else {
	engine.httpRequest(url, props.method, params, type, headers)
		.then(
			data => {
				next('success', data);
			},
			err => {
				engine.globalEvent.dispatchEvent('net-exception', err);
				next('exception', err);
			}
		);
}
