Skip to content

Commit 2bb89b8

Browse files
committed
added support for the Kuzzle "now" API route
1 parent 05a6c78 commit 2bb89b8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/kuzzle.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,20 +347,27 @@ Kuzzle.prototype.logout = function () {
347347

348348

349349
/**
350-
* Returns the current Kuzzle UTC timestamp
350+
* Return the current Kuzzle's UTC Epoch time, in milliseconds
351+
*
351352
* @param {responseCallback} cb - Handles the query response
352353
* @returns {object} this
353354
*/
354355
Kuzzle.prototype.now = function (cb) {
355356
this.isValid();
356357
this.callbackRequired('Kuzzle.now', cb);
357358

358-
// TODO
359-
cb(null, {now: 0xBADDCAFE});
359+
this.query(null, 'read', 'now', {}, function (err, res) {
360+
if (err) {
361+
return cb(err);
362+
}
363+
364+
cb(null, res.now);
365+
});
360366

361367
return this;
362368
};
363369

370+
364371
/**
365372
* This is a low-level method, exposed to allow advanced SDK users to bypass high-level methods.
366373
* Base method used to send read queries to Kuzzle

0 commit comments

Comments
 (0)