When making an AJAX call to the server, I receive a response in the form of an array of objects as JSON.
[{"dms":[{"serialNo":"EG0022","status":"running","firmwareStatus":"ok","latitude":37.8688,"longitude":-144.2093,"toolType":1},{"serialNo":"EG0022","status":"running","firmwareStatus":"ok","latitude":31.8688,"longitude":-115.2093,"toolType":1}],"gyro":[{"serialNo":"EG0022","status":"running","firmwareStatus":"ok","latitude":37.8688,"longitude":-144.2093,"toolType":1},{"serialNo":"EG0022","status":"running","firmwareStatus":"ok","latitude":31.8688,"longitude":-115.2093,"toolType":1}]}]
After calling the success method and printing the data, I see [object, object] in the console. How can I parse this object of array of objects in the success method?
<!-- Import Polymer -->
<script src="../../bower_components/webcomponentsjs/webcomponentslite.js"></script>
<link rel="import" href="../../bower_components/polymer/polymer.html"/>
<link rel="import" href="../../bower_components/paper-item/paperitem.html">
<link rel="import" href="../../bower_components/paper-listbox/paperlistbox.html">
<link rel="import" href="../../bower_components/paper-dropdown-menu/paperdropdown-menu.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<!-- Seed app components -->
<dom-module id="tool-bar">
<template>
<iron-ajax
id="ajax"
url=" rest URL"
params='{"type":"all"}'
handle-as="json"
content-type="application/json"
method="GET"
on-response="mapResponse"
debounce-duration="3000">
</iron-ajax>
</template>
<script>
Polymer({
is : 'tool-bar',
properties: {
gyrodata: {
type: Array
}
},
mapResponse: function (data) {
console.log(data.detail.response); //[Object,Object]
}
});
</script>
</dom-module>