+ 6

Please help!!!!!How can i change this code to ionic code?

var postContainer=document.getElementsByClassName("post-con"); var postImg=document.getElementsByClassName("post-img"); var imgs=document.getElementsByTagName('img'); var postContainer1=document.getElementById("post-con1"); var ourRequest = new XMLHttpRequest(); ourRequest.open('GET','https://www.example.com/wp-json/wc/v1/products?fields=18&consumer_key=ck_12....7ca9e09e&consumer_secret=cs_8185efc7...4&per_page=100'); ourRequest.onload= function() { if(ourRequest.status >= 200 && ourRequest.status < 400){ var data = JSON.parse(ourRequest.responseText); createHTML(data); }else{ console.log("We connected to the server but return error."); } }; ourRequest.onerror=function(){ console.log("Connection error"); }; ourRequest.send(); function createHTML(postData){ var i=null; var ourHTMLString1=""; var ourHTMLString2=""; var number=0; var postCategories=""; //postContainer.innerHTML=postData.length; alert("test"); var aa=[]; var bb=[]; var cc=[]; var dd=[]; var ee=[]; var ff=[]; var gg=[]; var polomax=""; var j=0;k=0;l=0;m=0;n=0;o=0;p=0;q=0; var ourHTMLString3=""; var poloid=postData[0].categories[0].id; var polomax=[{a:aa},{b:bb},{c:cc},{d:dd},{e:ee},{f:ff},{g:gg}]; for(i=0;i<postData.length;i++){ postCategories=postData[i].images; if(i===14){continue;} //alert(postData[i].categories[0].id); switch(postData[i].categories[0].id){ case 45: aa[j]=postData[i]; j++; //postContainer[i].innerHTML=polomax[0].a[0].name; break; case 25: bb[k]=postData[i]; k++; break; case 16: cc[l]=postData[i]; l++ break; case 17: dd[m]=postData[i]; m++; break; case 20: ee[n]=postData[i]; n++; break; case 19: bb[o]=postData[i]; o++; break; case 18: ff[p]

16th Dec 2017, 5:24 AM
Wyut Yi Hnin
Wyut Yi Hnin - avatar
1 Odpowiedź
+ 6
use json format
17th Dec 2017, 5:19 PM
James16
James16 - avatar