Permalink
Browse files

only include Accept-Language in header if provided in constructor

  • Loading branch information...
1 parent f1f0065 commit 1da34aca7fe2385893e991e6c543181c8229038b Chris Quartier committed Jan 9, 2014
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/fitbit_client.js
View
@@ -15,13 +15,14 @@ var baseURI = 'http://api.fitbit.com/1';
module.exports = function (api_key, api_secret, callbackURI, unit_system) {
var client = {version: '0.1.0'};
var serializer = Serializer.createSecureSerializer(api_key, api_secret);
+ var headers = {'Accept': '*/*', 'Connection': 'close', 'User-Agent': 'fitbit-js ' + client.version};
+
+ if (typeof unit_system !== 'undefined' && unit_system !== null) headers['Accept-Language'] = unit_system;
var oAuth = new OAuth('http://api.fitbit.com/oauth/request_token',
'http://api.fitbit.com/oauth/access_token',
api_key, api_secret, '1.0', callbackURI,
- 'HMAC-SHA1', null,
- {'Accept': '*/*', 'Connection': 'close', 'User-Agent': 'fitbit-js ' + client.version, 'Accept-Language': unit_system});
-
+ 'HMAC-SHA1', null, headers);
function requestCallback(callback) {
return function (err, data, response) {

0 comments on commit 1da34ac

Please sign in to comment.