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


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

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


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

示例1:

	return new Promise<Post>((ok, ko) => {
		let params: any = {
			timestamp: timestamp
		};
		let reqPath = path.join('/v1/server/posts', timestamp.toString());
		let url = source + reqPath;

		if(idtoken && sigtoken) {
			params.idToken = idtoken;
			let signature = utils.computeSignature('GET', url, params, sigtoken);
			url += '?idToken=' + idtoken
			url += '&signature=' + signature;
		}

		// We'll use HTTP only for localhost
		if(url.indexOf('localhost') < 0 && !commons.settings.forceHttp) url = 'https://' + url;
		else url = 'http://' + url

		log.debug('Requesting GET ' + url);

		request.get(url, {timeout: commons.settings.timeout})
		.then((response) => {
			log.debug('Received a post from ' + source);
			ok(JSON.parse(response));
		}).catch(ko);
	})
開發者ID:JosephCaillet,項目名稱:cozy-vinimay,代碼行數:26,代碼來源:postUtils.ts

示例2: icb

      (x: string, icb) => {
        const url = this.baseUrl + '/fee/' + x;
        this.request
          .get(url, {})
          .then(ret => {
            try {
              ret = JSON.parse(ret);

              // only process right responses.
              if (!_.isUndefined(ret.blocks) && ret.blocks != x) {
                log.info(`Ignoring response for ${x}:` + JSON.stringify(ret));
                return icb();
              }

              result[x] = ret.feerate;
            } catch (e) {
              log.warn('fee error:', e);
            }

            return icb();
          })
          .catch(err => {
            return icb(err);
          });
      },
開發者ID:bitpay,項目名稱:bitcore,代碼行數:25,代碼來源:v8.ts

示例3: verifyUUIDisNew

    public async verifyUUIDisNew(): Promise<boolean> {
        const options = {
            uri: `https://api.bespoken.link/pipe/${ this._secretKey }`,
            headers: {
                "x-access-token": "4772616365-46696f72656c6c61",
            },
            body: {

            },
            json: true, // Automatically parses the JSON string in the response
            timeout: 30000
        };

        try {
            await get(options);
        } catch (error) {
            if (error.statusCode && error.statusCode !== 404) {
                // different kind of error, we log and throw
                LoggingHelper.error(Logger, `Error while verifying id: ${ error.message }`);
                throw error;
            }
            // uuid doesn't exist
            return true;
        }

        return false;
    };
開發者ID:bespoken,項目名稱:bst,代碼行數:27,代碼來源:spokes.ts

示例4: getAddressTxos

 async getAddressTxos(params) {
   const { unspent, address } = params;
   const args = unspent ? `?unspent=${unspent}` : '';
   const url = `${this.baseUrl}/address/${address}${args}`;
   return request.get(url, {
     json: true
   });
 }
開發者ID:bitpay,項目名稱:bitcore,代碼行數:8,代碼來源:client.ts

示例5: callService

 public async callService() {
     const options = {
         uri: "https://source-api.bespoken.tools/v1/sourceId",
         json: true,
         timeout: 30000
     };
     return get(options);
 };
開發者ID:bespoken,項目名稱:bst,代碼行數:8,代碼來源:source-name-generator.ts

示例6: getTx

 async getTx(params) {
   const { txid } = params;
   const url = `${this.baseUrl}/tx/${txid}`;
   console.log('[client.js.59:url:]', url); // TODO
   return request.get(url, {
     json: true
   });
 }
開發者ID:bitpay,項目名稱:bitcore,代碼行數:8,代碼來源:client.ts

示例7: getRank

 getRank(id: number): Promise<Score> {
     return request.get(Configuration.ServerWithApiUrl + id).then(result => {
         let json = JSON.parse(result)[0];
         return Score.FromJson(json);
     }).catch((err) => {
         console.error(err);
         return err;
     });
 }
開發者ID:jpoon,項目名稱:flappy-bird-muzik,代碼行數:9,代碼來源:leaderboard.ts

示例8: postScore

 postScore(username: string, score: number): Promise<Score> {
     return request.get(Configuration.ServerWithApiUrl + 'create?username=' + username + '&score=' + score).then(result => {
         let json = JSON.parse(result);
         return Score.FromJson(json);
     }).catch((err) => {
         console.error(err);
         return err;
     });
 }
開發者ID:jpoon,項目名稱:flappy-bird-muzik,代碼行數:9,代碼來源:leaderboard.ts

示例9: if

http.createServer((req, resp) => {
  if (req.url === '/doodle.png') {
    if (req.method === 'PUT') {
      req.pipe(rpn.put('http://mysite.com/doodle.png'));
    } else if (req.method === 'GET' || req.method === 'HEAD') {
      rpn.get('http://mysite.com/doodle.png').pipe(resp);
    }
  }
});
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:9,代碼來源:request-promise-native-tests.ts

示例10: getCheckData

 async getCheckData(params) {
   const { payload, pubKey } = params;
   const url = `${this.baseUrl}/wallet/${pubKey}/check`;
   console.log('WALLET CHECK ', url); // TODO
   const signature = this.sign({ method: 'GET', url, payload });
   return request.get(url, {
     headers: { 'x-signature': signature },
     body: payload,
     json: true
   });
 }
開發者ID:bitpay,項目名稱:bitcore,代碼行數:11,代碼來源:client.ts


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