Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ module.exports = function (config, deps) {

var superagent = requireDep(deps, 'superagent');
var log = requireDep(deps, 'log');
var config = _.clone(config);

config = _.clone(config);
requireConfig(config, 'host');
requireConfig(config, 'metricsSource');
requireConfig(config, 'metricsVersion');
Expand Down Expand Up @@ -481,9 +481,13 @@ module.exports = function (config, deps) {
var syncTask = res.body;
var syncTaskId = syncTask.id;

if (!syncTaskId) {
if (syncTaskId == null) {
syncTaskId = res.body.syncTaskId;
}

if (syncTaskId == null) {
log.info('Upload Failed');
return cb({message: 'No sync task id'});
return cb({message: 'No sync task id', response: res.body});
}

waitForSyncTaskWithIdToFinish(syncTaskId,function(err,data){
Expand Down Expand Up @@ -520,6 +524,10 @@ module.exports = function (config, deps) {
return common.handleHttpError(res, cb);
}

if (res.headers['content-type'] === 'application/octet-stream') {
return superagent.parse.text(res, function(){ cb(null, res.text); });
}

return cb(null, res.text);
});
},
Expand Down
4 changes: 4 additions & 0 deletions tidepool.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
var superagent = require('superagent');
var _ = require('lodash');

var inMemStore = require('./lib/inMemoryStorage');
var makeClient = require('./index');

// Public-facing API, used by app developers
Expand Down Expand Up @@ -48,6 +49,9 @@ module.exports = function(options) {
removeItem: function() {}
};
}
if (localStore === 'memory') {
localStore = inMemStore();
}

return makeClient(_.omit(options, 'log', 'superagent', 'localStore'), {
log: log,
Expand Down
4 changes: 4 additions & 0 deletions user.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ module.exports = function (common, config, deps) {
if (err != null) {
return cb(err);
}
if (res.error) {
return cb(res.error)
}

var theUserId = res.body.userid;
var theToken = res.headers[common.SESSION_TOKEN_HEADER];

Expand Down