本文整理汇总了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);
})
示例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);
});
},
示例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;
};
示例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
});
}
示例5: callService
public async callService() {
const options = {
uri: "https://source-api.bespoken.tools/v1/sourceId",
json: true,
timeout: 30000
};
return get(options);
};
示例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
});
}
示例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;
});
}
示例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;
});
}
示例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);
}
}
});
示例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
});
}