Skip to content

Commit

Permalink
fix: use reject handler instead of catch for callbacks (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed May 11, 2018
1 parent f3347c5 commit 25c3f8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion samples/urlshortener/urlshortener.js
Expand Up @@ -18,7 +18,11 @@ const path = require('path');
const nconf = require('nconf');

nconf.argv().env().file(path.join(__dirname, '../config.json'));
const urlshortener = google.urlshortener('v1', nconf.get('api_key'));

const urlshortener = google.urlshortener({
version: 'v1',
auth: nconf.get('api_key')
});

urlshortener.url.get({
shortUrl: 'http://goo.gl/DdUKX'
Expand Down
4 changes: 1 addition & 3 deletions src/lib/apirequest.ts
Expand Up @@ -59,9 +59,7 @@ export function createAPIRequest<T>(
parameters: APIRequestParams, callback?: BodyResponseCallback<T>): void|
AxiosPromise<T> {
if (callback) {
createAPIRequestAsync<T>(parameters)
.then(r => callback(null, r))
.catch(e => callback(e));
createAPIRequestAsync<T>(parameters).then(r => callback(null, r), callback);
} else {
return createAPIRequestAsync(parameters);
}
Expand Down

0 comments on commit 25c3f8e

Please sign in to comment.