本文整理匯總了TypeScript中restify.Client類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Client類的具體用法?TypeScript Client怎麽用?TypeScript Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Client類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('returns an error when no url is provided', (done)=> {
client.post('/shorten', {}, (err, req, res: restify.Response, data)=> {
expect(res.statusCode).to.equal(400);
expect(res.headers['content-type']).to.equal('application/json');
expect(data.message).to.equal('url is not present');
done();
});
});
示例2: expect
client.post('/shorten', {'url': 'http://test.url', shortcode}, ()=> {
client.post('/shorten', {
'url': 'http://test2.url',
shortcode
}, (err, req, res: restify.Response, data)=> {
expect(res.statusCode).to.equal(409);
expect(data.message).to.equal('The desired shortcode is already in use.');
done();
});
});
示例3: function
let doShortenRequest = function (body, callback) {
client.post('/shorten', body, callback);
};