I'm learning Polymer 1.8 and I'm trying to get data from an api.
after that i want to bind data from my ontap() function with a dom-repeate, but I'm getting a weird error in the console:
[dom-repeat::dom-repeat]: expected array for items
, found [{"requestnum":"1045","orgid":"EAGLENA"},{"requestnum":"1046","orgid":"EAGLENA"},{"requestnum":"1047","orgid":"EAGLENA"},{"requestnum":"1048","orgid":"EAGLENA"},{"requestnum":"1049","orgid":"EAGLENA"}]
i can't solve this problem could any one help me?
What is wrong in this code????
im using polymer 1.8
*this is my html file maximo-test-card.html:
<dom-module id="maximo-test-card">
<template>
<template is="dom-repeat" items="{{hi}}">
<li>
<span>{{item.requestnum}}</span>
</li>
</template>
<div>{{hi}}</div>
<iron-ajax
id="requestRepos"
headers='{"Content-Type": "application/json", "Accept": "someAccept", "Authorization": "someAuthorizationToken"}'
url="http://vaganet.vaganet.fr:9080/maximo/oslc/os/mxinvres?oslc.select=*"
handle-as="json"
on-response="ontap"> </iron-ajax> </template>
<script src="maximo-test-card.js"></script>
</dom-module>
*this is my js file maximo-test-card.js:
Polymer({
is: 'maximo-test-card',
properties: {
repos: {
type: Array
},
githubrepository:{
type: Array
},
hi:{
type: Array,
},
},
ready: function () {
this.$.requestRepos.generateRequest();
//console.log(hi)
//this.name=hi
},
ontap: function (data) {
this.repos = data.detail.response.member;
hi = []
for (var i = 0; i < 5; i++) {
hi[i] = {"requestnum":this.repos[i].requestnum,"orgid":this.repos[i].orgid}
}
this.hi = JSON.stringify(hi)
alert(this.hi);
return this.hi;
},
});