Skip to content

Commit

Permalink
xml_parser only needed there
Browse files Browse the repository at this point in the history
  • Loading branch information
mastef committed Mar 8, 2018
1 parent 689c56c commit f4c929a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ var GoogleSpreadsheet = function( ss_key, auth_id, options ){

options = options || {};

var xml_parser = new xml2js.Parser({
// options carried over from older version of xml2js
// might want to update how the code works, but for now this is fine
explicitArray: false,
explicitRoot: false
});


if ( !ss_key ) {
throw new Error("Spreadsheet key not provided.");
Expand Down Expand Up @@ -162,8 +157,18 @@ var GoogleSpreadsheet = function( ss_key, auth_id, options ){


if ( body ){
var xml_parser = new xml2js.Parser({
// options carried over from older version of xml2js
// might want to update how the code works, but for now this is fine
explicitArray: false,
explicitRoot: false
});
xml_parser.parseString(body, function(err, result){
if ( err ) return cb( err );
if ( err ) {
xml_parser = null;
body = null;
return cb( err );
}
if(cb.length == 3) {
cb( null, result, body );
}else{
Expand Down

0 comments on commit f4c929a

Please sign in to comment.