Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise #237

Open
satkamar opened this issue Oct 4, 2018 · 2 comments
Open

Promise #237

satkamar opened this issue Oct 4, 2018 · 2 comments

Comments

@satkamar
Copy link

satkamar commented Oct 4, 2018

Please guide me to use in promise.

@libe-max
Copy link

libe-max commented Oct 18, 2018

Hey
Here is what I did :

const webshotPromise = (dom, out, opt) => new Promise((resolve, reject) => {
  webshot(dom, out, opt, e => !e
    ? resolve('screenshot taken')
    : reject(e)
  )
})

@l3aconator
Copy link

that works wonderfully! Thank you. I modified it for async/await for use in graphql.

const webshotPromise = async (html, screenPath, options) =>
  new Promise((resolve, reject) => {
    webshot(
      html,
      screenPath,
      options,
      e => (!e ? resolve(screenPath) : reject(e))
    );
  });

const finishedImage = await webshotPromise(html, screenPath, optionsLarge);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants