當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript request-promise-json.get函數代碼示例

本文整理匯總了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));
            })



        })
開發者ID:dottgonzo,項目名稱:couch-autho,代碼行數:28,代碼來源:main.ts

示例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)
        })
    })
開發者ID:dottgonzo,項目名稱:couch-autho,代碼行數:11,代碼來源:index.ts

示例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) => {
開發者ID:dottgonzo,項目名稱:couch-autho,代碼行數:36,代碼來源:main.ts

示例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)
            })
        })


    }
開發者ID:dottgonzo,項目名稱:couch-autho,代碼行數:82,代碼來源:index.ts


注:本文中的request-promise-json.get函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。