ianmcook commented on code in PR #39081:
URL: https://github.com/apache/arrow/pull/39081#discussion_r1433108979


##########
http/examples/get/client.js:
##########
@@ -0,0 +1,29 @@
+const Arrow = require('apache-arrow');
+
+const url = 'http://localhost:8000';
+
+async function getArrowData(url) {
+  try {
+    const response = await fetch(url);
+    const table = await Arrow.tableFromIPC(response);
+    return table;
+  } catch (error) {
+    console.error('Error:', error.message);
+    throw error;
+  }
+}
+
+async function runExample(url) {
+  const startTime = new Date();
+  try {
+    const table = await getArrowData(url);
+    const endTime = new Date();
+    const duration = (endTime - startTime) / 1000;
+    console.log(`${table.batches.length} record batches received`);
+    console.log(`${duration.toFixed(2)} seconds elapsed`);
+  } catch (error) {
+    console.error('Error:', error.message);
+  }
+}
+
+runExample(url);

Review Comment:
   @domoritz I cleaned this up to use all async. LMK if there's anything else 
that could be improved here. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to