react native insertion of array values using react-native-sqlite-storage

我们两清 提交于 2021-02-08 11:41:59

问题


i am trying to insert array values into some table for sqlite. my arrays values are not inserted. i am strucked here that was i tried can you guide me in correct way here i am getting the response from axion json output. response.zonedetails is a array. for (var i = 0; i < response.zoneDetails.length; i++){

      console.log('hi i am ');
      console.log('for loop log',response.zoneDetails[i]);

        var zoneNmae = response.zoneDetails[i].zonename;
        var parentZoneId = response.zoneDetails[i].parentzoneid;
        var levelId = response.zoneDetails[i].levelid;
        var zoneId = response.zoneDetails[i].zoneid;

   await this.setState({zonename: zoneNmae});
   await this.setState({zoneId:zoneId});
   await this.setState({parentzoneid: parentZoneId });
   await this.setState({levelid:levelId});
   this.initZonesDB();
   //this.addZonesdetailsInfo(response.zoneDetails);
   this.addZonesdetailsInfo();

this is my response :"zoneDetails": [ { "zonename": "zone1", "zoneid": 1, "parentzoneid": 10, "levelid": "2" }, { "zonename": "zone2", "zoneid": 2, "parentzoneid": 10, "levelid": "2" },

i am unable to insert all values every time,it was inserting first array of 1st index values only [0]. can any one suggest me to insert all values in good way for react native.

来源:https://stackoverflow.com/questions/57924039/react-native-insertion-of-array-values-using-react-native-sqlite-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!