Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48979

Http get not firing after successful barcode scan using async and await

$
0
0

I’m having trouble running an HttpClient GET function after a successful scan of a barcode. The barcode scanning is working but when I pass the barcode value to my get function nothing happens. I’m using async and await but must be missing something.

My HTTP GET function:

getOrderFromShopify(requestUrl: any) {
  
  this.http.get(requestUrl)
    .subscribe(data => {
      console.log(data);
      this.order_details = data["order"];
      this.line_items = data["order"]["line_items"];
    })
}

My Barcode Scan function:

async scanCode() {
    this.barcodeScanner
      .scan()
      .then(async barcodeData => {

        const baseURL = 'https://xxxxxxx.xxx?';
        const queryOptions = 'order_name=' + barcodeData.text; //Keep going
        let requestUrl = `${baseURL}${queryOptions}`;

        await this.getOrderFromShopify(requestUrl);

        this.scannedData = barcodeData;
      })
      .catch(err => {
        console.log("Error", err);
      });
  }

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>