Pregunta

I am trying to get a .json of the list of tasks using a javascript. Sadly, I have had a sore time trying to find javascript specific documentation, so I don't even know where to start. Answering this one basic question would be great, but if someone could point me in the direction of the javascript api docs, I would love you forever! Prefferably both though.

¿Fue útil?

Solución

You really need to do this on the server rather than in javascript on the browser as the latter exposes your API key to the world (and probably violates Asana's terms of service)

Look at the API docs (https://asana.com/developers/api-reference/tasks) under the heading "QUERYING FOR TASKS" to get the details. From the command line you would type the following (assuming you have curl):

curl -u <api_key>: "https://app.asana.com/api/1.0/tasks?workspace=14916&assignee=me"

Most server side languages will have a mechanism for doing the equivalent from within a script.

If you need the json delivered to the browser, you would:

  1. Fire off an AJAX request to the server, providing the appropriate details
  2. In your script convert the request into a call to the Asana API (adding your API Key)
  3. Receive result on the server from Asana and echo to client.
  4. Process JSON in javascript.

Bear in mind that this is potentially an expensive operation in terms of the performance of your server. Depending on the setup/language you are using, you may need to plan carefully to ensure that the Asana api requests are not blocking other requests (they need to happen asynchronously).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top