本文整理汇总了TypeScript中request-promise-json.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("check slave", function (done) {
rpj.get(CouchAuth.my('_users/org.couchdb.user:' + slave.username)).then((d) => {
expect(d).to.be.ok;
expect(d).to.have.property('name').that.eq(slave.username);
expect(d).to.have.property('roles').that.is.an('array');
expect(d.roles[0]).to.be.eq('slave');
expect(d).to.have.property('app').that.is.an('object');
expect(d.app).to.have.property('db').that.is.a('string');
expect(d.app).to.have.property('user').that.is.a('string');
expect(d).to.have.property('dbtype').that.is.a('string').that.eq('userslave');
expect(d).to.have.property('type').that.is.a('string').that.eq('user');
done();
}).catch((err) => {
done(Error(err));
})
})
示例2: Error
return new Promise<IUserDB>(function (resolve, reject) {
rpj.get(internal_couchdb.my('_users/org.couchdb.user:' + username)).then(function (doc) {
resolve(doc)
}).catch(function (err) {
if (err.statusCode != 404) {
throw Error("ERROR!!!" + err)
}
reject(err)
})
})
示例3: expect
CouchAuth.register({ username: user0.user, password: user0.password, email: user0.email, app_id: 'testapp' }).then(function () {
rpj.get(CouchAuth.my('_users/org.couchdb.user:' + user0.user)).then(function (d) {
expect(d).to.be.ok;
expect(d).to.have.property('name').that.eq(user0.user);
expect(d).to.have.property('email').that.eq(user0.email);
expect(d).to.have.property('roles').that.is.an('array');
expect(d.roles[0]).to.be.eq('user');
expect(d).to.have.property('type').that.eq('user');
expect(d).to.have.property('db').that.is.an('array');
expect(d.db[0]).to.have.property('app_id').that.is.a('string').that.eq('testapp');
expect(d.db[0]).to.have.property('dbname').that.is.a('string');
expect(d.db[0]).to.have.property('dbtype').that.is.a('string').that.eq('mine');
expect(d.db[0]).to.have.property('roles').that.is.an('array');
expect(d.db[0].roles[0]).to.be.eq('owner');
expect(d.db[0]).to.have.property('slave').that.is.an('object');
expect(d.db[0].slave).to.have.property('username').that.is.a('string');
expect(d.db[0].slave).to.have.property('password').that.is.a('string');
slave = d.db[0].slave;
done();
}).catch((err) => {
done(Error(err));
})
}).catch((err) => {
示例4: constructor
constructor(rootaccessdb: IClassConf) {
super(rootaccessdb)
let that = this;
function addAdminRole() {
that.addAppRole(that.user, 'main').then(() => {
console.log("created!")
return true
}).catch((err) => {
console.log("errRRR " + err)
})
}
rpj.get(that.my('app_main')).then(function () {
getuserdb(that, that.user).then((u) => {
if (u.roles.indexOf('app_main') != -1) {
addAdminRole()
} else {
console.log("created!")
return true
}
}).catch((err) => {
that.createUser(that.user, that.password, '').then(() => {
addAdminRole()
}).catch((err) => {
console.error("err " + err)
})
})
}).catch(function (err) {
that.createapp('main').then(() => {
getuserdb(that, that.user).then((u) => {
if (u.roles.indexOf('app_main') != -1) {
addAdminRole()
} else {
console.log("created!")
return true
}
}).catch((err) => {
that.createUser(that.user, that.password, '').then(() => {
addAdminRole()
}).catch((err) => {
console.error("err " + err)
})
})
}).catch((err) => {
console.error("err " + err)
})
})
}