Search code examples
tasker

tasker for android - not able to get response from HTTP get request


I am trying to get some data out of google maps API.

The response comes trough, as I can see it, but when I try to use a javascriptlet, i have no luck.

this is my current setup:

I get the data from google maps:

Server:port: http://maps.google.com/maps/api/geocode/json?latlng=%LOCN&sensor=false

I run the javascriptlet trying to get only the value I need out from the json object:

var response = global ('HTTPD');
var gmapslocationname = response.results[0].address_components[2].short_name

and then I try to flash it:

%gmapslocationname 

but what I get in the flash is %gmapslocationname

What am I doing wrong here?

thanks


Solution

  • Tasker is not capable of handling objects, hence the HTTPD is stored as a string. To be able to use it, you need to convert it to object.

    Change your code to

    var response = global ('HTTPD');
    var gmobject = JSON.parse(response);
    var gmapslocationname = gmobject.results[0].address_components[2].short_name