3

I am using Wunderlist SDK for a sample app that im developing for academic purposes.

From the Wunderlist's docs i have the following code working:

$(document).ready(function(){
   var WunderlistSDK = window.wunderlist.sdk;
   WunderlistAPI = new WunderlistSDK({
      'accessToken': access_token,
      'clientID': client_id
   });

   WunderlistAPI.initialized.done(function () {
       WunderlistAPI.http.lists.all().done(handleListData).fail(handleError);
   });

   function handleListData(data){
       $("#tasks").append("<button onclick='lookup_tasks(" + data.id + ")'>Search tasks for this list</button>");
   }

   function handleError(error,event){
      alert("Error: "+ JSON.stringify(error));
   }
});

I am confused on using the the rest of the API because i cant figure out how can i perform other requests using the REST API

For instance if i want to search all tasks by a list_id i am trying the following but it wont work:

function lookup_tasks(list_id){
    $.get("http://a.wunderlist.com/api/v1/tasks",{list_id: list_id},function(data){
        alert(JSON.stringify(data));
    }); //Neither works passing the client_id and access_token as params
}

Anyone knows what am i misunderstanding?

damuz91
  • 1,461
  • 2
  • 21
  • 37
  • The purpose of the Javascript SDK, is so you don't need to manually create the HTTP requests. Check out the API docs for more info - https://github.com/wunderlist/wunderlist.js#documentation – levi Jun 18 '15 at 20:52
  • 1
    That said, the reason you request is failing, is probably because you need to include the authorization headers in the HTTP request (which the SDK does for you). https://developer.wunderlist.com/documentation/concepts/authorization – levi Jun 18 '15 at 20:55
  • 1
    Indeed, i was very confused about the SDK and the API. https://github.com/wunderlist/wunderlist.js/blob/master/examples/UNDERLIST/underlist.js This file led me to understand what i need if im using the SDK. – damuz91 Jun 18 '15 at 21:40
  • If i want to use the API, how can i set those headers with the authorization info? I have tried $.ajax with no luck – damuz91 Jun 18 '15 at 21:41
  • 1
    http://stackoverflow.com/questions/7686827/how-can-i-add-a-custom-http-header-to-ajax-request-with-js-or-jquery – levi Jun 18 '15 at 22:31
  • Excellent, right now im using the API way, i found very confusing the SDK – damuz91 Jun 23 '15 at 01:24
  • 1
    @David Mauricio thanks for sharing the example page link. It helped me. – Qadir Hussain Feb 01 '19 at 07:28

0 Answers0