question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Promise API

See original GitHub issue

Are there any plans to add support for async/await Promise-style API calls?

Currently, I’m doing something like this const info = await promisify(spreadsheetInstance.getInfo)() but it’d be nice not to have to toss the wrapper on top.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jasonhargrovecommented, Dec 3, 2019

Callbacks? Yuck! Luckily Node has a function built-in:

  const util = require('util');
  const auth = {
    client_email: xxxxx,
    private_key: xxxxxxxx
  };
  const spreadsheet_id = xxx;
  const GoogleSpreadsheet = require('google-spreadsheet');
  const doc = new GoogleSpreadsheet(spreadsheet_id );
  await util.promisify(doc.useServiceAccountAuth)(auth);
  const info = await util.promisify(doc.getInfo)();
1reaction
theoephraimcommented, Feb 3, 2020

I’ve just a published a new version of this module which is a complete rewrite using Google’s V4 Sheets API (v3 is being deprecated on March 3, 2020). Docs available here - https://theoephraim.github.io/node-google-spreadsheet

The new version is totally promise based. TBH I never liked using raw promises (.then/.catch) but with the addition of async/await, now it’s great 😃

Thanks! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise - JavaScript - MDN Web Docs
A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with...
Read more >
Promise API - The Modern JavaScript Tutorial
Promise.all(promises) – waits for all promises to resolve and returns an array of their results. If any of the given promises rejects, it ......
Read more >
Promises | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
API Reference - Promises
Returns a Promise that waits for all promises in the iterable to be fulfilled ... It is supported by most major promise libraries...
Read more >
Support for Promises in the SDK | AWS Developer Tools Blog
Today's release of the AWS SDK for JavaScript (v2.3.0) introduces support for promises when calling service operations. Promises provide an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found