Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Commit

Permalink
Add api-call to retrieve list status
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneCL committed May 19, 2018
1 parent a25389c commit fbe92f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
21 changes: 17 additions & 4 deletions api_debug_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function retrieveTodos(wunderlist, listID) {
wunderlist
.retrieveTodos(listID)
.then(function(resp) {
console.log(resp);
console.log(JSON.stringify(resp));
})
.catch(function(err) {
console.log(err);
Expand All @@ -19,7 +19,18 @@ function retrieveUsers(wunderlist) {
wunderlist
.retrieveUsers()
.then(function(resp) {
console.log(resp);
console.log(JSON.stringify(resp));
})
.catch(function(err) {
console.log(err);
});
}

function retrieveList(wunderlist, listID) {
wunderlist
.retrieveList(listID)
.then(function(resp) {
console.log(JSON.stringify(resp));
})
.catch(function(err) {
console.log(err);
Expand All @@ -31,7 +42,7 @@ function retrieveLists(wunderlist) {
wunderlist
.retrieveLists()
.then(function(resp) {
console.log(resp);
console.log(JSON.stringify(resp));
resolve(resp);
})
.catch(function(err) {
Expand All @@ -44,7 +55,9 @@ function retrieveLists(wunderlist) {
var wunderlist = new Wunderlist(clientID, accessToken);
retrieveLists(wunderlist)
.then(function(lists) {
retrieveTodos(wunderlist, JSON.parse(lists)[0].id);
retrieveTodos(wunderlist, lists[0].id);
retrieveList(wunderlist, lists[0].id);

})
.catch();
retrieveUsers(wunderlist);
15 changes: 15 additions & 0 deletions wunderlist-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ var Wunderlist = function (clientID, accessToken) {
});
};

this.retrieveList = function (listID) {
return new Promise(function (resolve, reject) {
var options = defaults;
options.uri = endpoint + "lists/" + listID;

rp(options)
.then(function (resp) {
resolve(JSON.parse(resp));
})
.catch(function (err) {
reject(err);
});
});
};

this.retrieveUsers = function () {
return new Promise(function (resolve, reject) {
var options = defaults;
Expand Down

0 comments on commit fbe92f5

Please sign in to comment.