【问题标题】:'Cannot read property 'data' of undefined' nodeJS'无法读取未定义'nodeJS的属性'数据'
【发布时间】:2015-10-23 01:24:14
【问题描述】:

无法读取未定义的 nodeJS 的属性“数据”,我正在尝试使用 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);
});

【问题讨论】:

  • 回调中的err 参数用于检查错误。通常情况下,如果设置了,data参数是没有的。

标签: javascript node.js svn


【解决方案1】:

我认为数据字段未定义,因此出现错误。

试试这个,

Client.getInfo(function(err, data) {
    if(err) return console.log("The error is:",err);
    console.log('Repository url is:', data.url);
});

【讨论】:

    猜你喜欢
    • 2017-03-06
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    • 2022-11-29
    • 2023-02-17
    • 2020-08-13
    • 2017-06-17
    相关资源
    最近更新 更多