2

Cannot read property 'data' of undefined' nodeJS , i'am trying to commit directory using nodejs

var SvnLib = require('svnlib');
Client =  new SvnLib ({
   cwd: './Users/Safa/Desktop/test2',
   username: 'username', // optional if authentication not required or    is already saved
   password: 'password', // optional if authentication not required or is    already saved
});

Client.update(function(err, data) {
    console.log('updated');
});
Client.getInfo(function(err, data) {
    console.log('Repository url is %s', data.url);
});
Vishnu
  • 11,614
  • 6
  • 51
  • 90
Safa
  • 107
  • 2
  • 9
  • The `err` parameter in the callback is there for you to check for errors. Usually, if it is set, the `data` parameter is not. – Sirko Jul 31 '15 at 11:22

1 Answers1

1

I think the data field is undefined and hence the error.

Try this,

Client.getInfo(function(err, data) {
    if(err) return console.log("The error is:",err);
    console.log('Repository url is:', data.url);
});
Aman Gupta
  • 3,627
  • 4
  • 40
  • 64