http Requests on Ionic # 3

0

I have a tremendous confusion. I have my function perfectly

getPromociones(id:any){

      //
      var url = "https:/xxx/promociones/ObtenerPromociones?IdCategoria="+id;
      return this.http.get(url).subscribe(
         (data)=>{
            this.itemsdata=[];
            this.data1 = data['Promociones'];            
            for(var i = 0; i <this.data1.length; i++){
                  //console.log('contador'+ i +' '+JSON.stringify(this.data[i]['Titulo']));
                  this.itemsdata[i] = {
                     "id":this.data1[i]['IdPromocion'],
                     "title":this.data1[i]['Titulo'],
                     "description":this.data1[i]['Descripcion'],
                     "image":this.data1[i]['Url'],
                     "precioUnitario":this.data1[i]['PrecioUnitario'],
                     "precioPromo":this.data1[i]['PrecioPromocional'],
                     "imageAlt":"avatar",
                     "icon":"icon-heart-outline",
                     "duration":this.data1[i]['PorcentajeDescuento']
                  }
            }
            this.data2={"headerImage":"assets/images/background/14.jpg",
            "toolBarTitle":"Product",
            "title":"Super discount",
            "description":"50% OFF",
            "iconLike":"icon-thumb-up",
            "iconCar":"icon-cart-arrow-down",
            "iconFavorite":"icon-heart",
            "iconShare":"icon-share-variant",
            "items":this.itemsdata

            }
            //this.toastCtrl.presentToast(JSON.stringify(this.data2));
            console.log(JSON.stringify(this.data2));

         },error=>{
            console.error("error en la peticione");
         });


    }

when the test on my local computer everything excellent. The problem is that when I generate the apk, the phone does not leave anything and I show an alert and the request comes empty ..

I'm already going crazy. thanks to the customer

    
asked by developer 10.04.2018 в 17:24
source

1 answer

0
getPromociones(id:any){

      //
      var url = "http:/xxx/promociones/ObtenerPromociones?IdCategoria="+id;
      return this.http.get(url).subscribe(
         (data)=>{
            this.itemsdata=[];
            this.data1 = data['Promociones'];            
            for(var i = 0; i <this.data1.length; i++){
                  //console.log('contador'+ i +' '+JSON.stringify(this.data[i]['Titulo']));
                  this.itemsdata[i] = {
                     "id":this.data1[i]['IdPromocion'],
                     "title":this.data1[i]['Titulo'],
                     "description":this.data1[i]['Descripcion'],
                     "image":this.data1[i]['Url'],
                     "precioUnitario":this.data1[i]['PrecioUnitario'],
                     "precioPromo":this.data1[i]['PrecioPromocional'],
                     "imageAlt":"avatar",
                     "icon":"icon-heart-outline",
                     "duration":this.data1[i]['PorcentajeDescuento']
                  }
            }
            this.data2={"headerImage":"assets/images/background/14.jpg",
            "toolBarTitle":"Product",
            "title":"Super discount",
            "description":"50% OFF",
            "iconLike":"icon-thumb-up",
            "iconCar":"icon-cart-arrow-down",
            "iconFavorite":"icon-heart",
            "iconShare":"icon-share-variant",
            "items":this.itemsdata

            }
            //this.toastCtrl.presentToast(JSON.stringify(this.data2));
            console.log(JSON.stringify(this.data2));

         },error=>{
            console.error("error en la peticione");
         });


    }

The solution was easy but something strange .. just change the url from "https: // to" http: // ". On the web the two forms work, but in the android phone 4.4 only brought the requests initiated with "http" without the (s). which is weird because I have other views with "https" and it still works .. but that was the solution

    
answered by 11.04.2018 в 23:09