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