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


TypeScript superagent.get函數代碼示例

本文整理匯總了TypeScript中superagent.get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript get函數的具體用法?TypeScript get怎麽用?TypeScript get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了get函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: reject

        return new Promise<any>((resolve, reject) => {

            if (_this.auth) {
                superagent.get(_this.couchdb + "/" + _id).set('Content-Type', 'application/json').auth(_this.auth.user, _this.auth.password).end((err, res) => {
                    if (err) {
                        reject(err);
                    } else {
                        resolve(JSON.parse(res.text));
                    }
                })
            } else {
                superagent.get(_this.couchdb + "/" + _id).set('Content-Type', 'application/json').end((err, res) => {
                    if (err) {
                        reject(err);
                    } else {


                        resolve(JSON.parse(res.text));
                    }
                })
            }



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

示例2: next

app.get('/', (req, res, next) => {
    superagent.get('https://cnodejs.org/')
        .end((err, sres) => {
            //  常規的錯誤處理
            if (err) {
                return next(err);
            }
            // sres.text 裏麵存儲著網頁的html內容,將它傳給cheerio.load 之後
            // 就可以得到一個實現了jquery 接口的變量,我們習慣性地將它命名為‘$’
            // 剩下的就是jquery 的內容
            var $ = cheerio.load(sres.text);
            var items = [];
                
            $('#main .topic_title').each((index, element) => {
                var $element = $(element);
                // attr href title
                items.push({
                    title: $element.attr('title'),
                    href: $element.attr('href'),
                    text:$element.text()
                });
            });
            res.send(items);
        });

});
開發者ID:wangyibu,項目名稱:node-lessons,代碼行數:26,代碼來源:demo.ts

示例3: deleteVirtualStudy

 deleteVirtualStudy(id:string){
     return request
             .get(`${getVirtualStudyServiceUrl()}/delete/${id}`)
             // @ts-ignore: this method comes from caching plugin and isn't in typing
             .forceUpdate(true)
                          
 }
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:7,代碼來源:sessionServiceAPI.ts

示例4: is_user_verified

        request.get(request_api_user).query({access_token}).end(async (err, result) => {
          let data = provider === 'github' ? result.body : JSON.parse(result.text)
          let user:any = { id: data.id, email: data.email }
          user.name = provider === 'github' ? data.login : data.name
          user.verified = is_user_verified(provider, data)
          if(provider === 'github' && !user.email) {
            let resp_email = await request.get(EMAIL_API_GITHUB).query({access_token})
            user.email = await get_primary_email(resp_email.body)
          }

          let found_user = await pendingUser.get(user.id)
          const encryptedSocialEmail = CryptoJS.AES.encrypt(user.email, process.env.DECRYPT_KEY);

          if(found_user) {
            found_user.social_verified = user.verified
            found_user.social_email = encryptedSocialEmail;
            found_user.social_name = user.name
            await found_user.save()
            res.status(200).json({user: found_user, access_token})
          } else {
            let salt = generate_rnd_string(4)
            user = await pendingUser.create({ social_name: user.name, social_id: user.id, social_verified: user.verified, social_email: encryptedSocialEmail, social_provider: provider, salt })
            res.status(200).json({user, access_token})
          }
        })
開發者ID:eastmaels,項目名稱:v2.api.utopian.io,代碼行數:25,代碼來源:social_login.controller.ts

示例5:

 topicUrls.forEach((topicUrl) => {
     superagent.get(topicUrl)
         .end((err, res) => {
             console.log('fetch ' + topicUrl + ' successful');
             ep.emit('topic_html', [topicUrl, res.text]);
         });
 });
開發者ID:wangyibu,項目名稱:node-lessons,代碼行數:7,代碼來源:demo.ts

示例6: request

  export function request(req, res, next) {

    console.log('request');

    var request = require('superagent');

    // example of giving res.data precedence 
    var url = res.data.url || this.config.url;

    if(url) {

    request.get(url).end(function(ret) {

        if(ret.ok) {

          //res.data.context = JSON.parse(ret.text ? ret.text : ret.body);
          // in case of json, we set .context
          res.data.context = Object.keys(ret.body).length ? ret.body : ret.text;

        } else {
          res.data.context = { status: 'error', message: ret.text };
        }

        next();

    });

    } else {
       res.data.context = { status: 'error', message: "request needs a config.url" };
       next();
    }

  };
開發者ID:psichi,項目名稱:chix-modules,代碼行數:33,代碼來源:module.ts

示例7: it

        it("verificate working of 2 localization", function (done) {


    superagent.get("https://emnetserver.kernel.online/auth/authorize/couchdb/testemnet/testemnet0101").end((err, res) => {
        if (err) {
            done(Error(err));
        } else if (res && res.body && !res.body.error) {

            const obj = res.body;

            token = obj.token;

            loc.setPosition(latlng2, token).then((c) => {

                expect(loc.state).to.be.an('Object');
                expect(c).to.be.an('Array');
                expect(c[0]).to.be.an('Object');
                expect(c[0].nativeName).to.be.a('string');
                done()
            }).catch((c) => {
                done(Error(c))
            })


        } else {
            done(Error(res.body.error))
        }
    })



        })
開發者ID:dottgonzo,項目名稱:remote-geo,代碼行數:32,代碼來源:remote.ts

示例8: return

		return (dispatch: Redux.Dispatch) => {
			superagent.get(`http://api.coindesk.com/v1/bpi/currentprice/${currency}.json`)
				.end((err : Error, body : any) => {
					if (!err && (body && body.text)) {
						dispatch(ActionsCreators.getCurrentPrice(JSON.parse(body.text)));
					}
				});
		};
開發者ID:ashelley,項目名稱:react-redux-typescript-bitcoin,代碼行數:8,代碼來源:bitcoin.ts

示例9: co

    return co(function *getAddressInfoFromExplorer() {
      const addrInfo = yield request.get(this.recoveryBlockchainExplorerUrl(`/addr/${addressBase58}`)).result();

      addrInfo.txCount = addrInfo.txApperances;
      addrInfo.totalBalance = addrInfo.balanceSat;

      return addrInfo;
    }).call(this);
開發者ID:BitGo,項目名稱:BitGoJS,代碼行數:8,代碼來源:bch.ts


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