你能试试我刚刚从这里更新的 sample.js 脚本吗:
https://github.com/versionone/VersionOne.SDK.JavaScript/blob/master/sample.js
它像这样引入两个模块:
var V1Meta = require('./v1meta').V1Meta;
var V1Server = require('./client').V1Server;
var hostname = "www14.v1host.com";
var instance = "v1sdktesting";
var username = "api";
var password = "api";
var port = "443";
var protocol = "https";
var server = new V1Server(hostname, instance, username, password, port, protocol);
var v1 = new V1Meta(server);
v1.query({
from: "Member",
where: {
IsSelf: 'true'
},
select: ['Email', 'Username', 'ID'],
success: function(result) {
console.log(result.Email);
console.log(result.Username);
console.log(result.ID);
},
error: function(err) { // NOTE: this is not working correctly yet, not called...
console.log(err);
}
});
您可能必须从 CoffeeScript 获取最新版本并构建 JS。
我想我去年尝试了“browserify”,这就是“v1sdk.js”文件的生成方式。但我不确定如果您使用的是 node.js 是否是最好的方法。最好按照 sample.js 文件的方式来做。
但是,为了方便起见,我还检查了对 v1sdk.coffee 的更改,该属性导出了其他两个模块。有了它,您可以查看 sample2.js。唯一不同的部分是这个,这更像是你试图用你的例子做的:
var v1sdk = require('./v1sdk');
var hostname = "www14.v1host.com";
var instance = "v1sdktesting";
var username = "api";
var password = "api";
var port = "443";
var protocol = "https";
var server = new v1sdk.V1Server(hostname, instance, username, password, port, protocol);
var v1 = new v1sdk.V1Meta(server);