const ExportAPI = {

	run(script, callback) {
		var url = '/export?s=' + script;
		var xhr = new XMLHttpRequest();
		xhr.onreadystatechange = function() {
			if (xhr.readyState === XMLHttpRequest.DONE) {
				if(xhr.status === 200) {
					callback(JSON.parse(xhr.responseText));
				} else {
					callback(null);
				}
			}
		};
		xhr.open("GET", url);
		xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
		xhr.send();
	}
};

export default ExportAPI;
