Sander was kind enough to point out that this kind of function would work 
for returning two values from an async() function.  I did some reading and 
one evidently can also use Promise.all.   The code works well but now I 
don't know how to separate the returning values.  Printers is a simple 
comma delimited string.  Devices is a series of JSON objects.  
       
       const getDeviceData = async () => {
         try {
           var foo = await qz.websocket.connect();
           var devices = await qz.hid.listDevices(false);
           var printers = await qz.printers.find();
           var bar = await qz.websocket.disconnect();
           return [printers, devices];
          } catch (err) {
           console.log('qz error', err);
          }
        }  


If I use the syntax below to invoke the function, result is an array of 
mixed object types, an array of string and an array of objects.  I need to 
separate them somehow. 

        getDeviceData().then(result => {
          console.log("result = " + result);
       })  


I believe I need to "de-structure" the return values. I've seen syntax that 
looks something like the code below, but this version will not compile 
without errors.  The square brackets were seen in various posts but in this 
context it doesn't seem to work.

     getDeviceData().then([printers, devices] => {
          console.log(printers);
          console.log(devices);
       })  

I think I'm very close, but after a few hours of searching I'm stumped!

Harry



-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to