await-to-js icon indicating copy to clipboard operation
await-to-js copied to clipboard

Async await wrapper for easy error handling without try-catch

Results 13 await-to-js issues
Sort by recently updated
recently updated
newest added

When using this library, I needed to import with the following pattern: ``` import { to } from "await-to-js"; ``` Instead of the approach in the README: ``` import to...

Hey all, perhaps I'm not understanding something here Using `to` ` const [err, data] = await to(fetch('http://httpstat.us/500')); console.debug(err, data) ` Result: ![image](https://user-images.githubusercontent.com/236984/124684276-19c9e800-df12-11eb-985d-3a33c35ee63e.png) Shouldn't a 500 with a `response.ok = false`...

When using this library with [`algoliasearch`](https://github.com/algolia/algoliasearch-client-javascript) (whose return types are always [`Readonly`](https://github.com/algolia/algoliasearch-client-javascript/blob/master/packages/client-common/src/types/WaitablePromise.ts)), I've had to use a wrapper function so that I can update those types. This allows for more...

Also in this PR: 1. Dependency update 2. Change tslint to eslint as it seems to work better now 3. Add nvmrc file to 'kind of' lock the node version...

### Demo ``` function delay(time = 0) { return new Promise((reslove, reject) => { if (time > 2000) { reject(); } else { reslove(time); } }); }; const [error, data]...

Hi, I tried your repo in my little crypto project I use ccxt: ``` const ccxt = require('ccxt') let log = require('electron-log') let to = require('await-to-js') async withdraw(currency, amount, address,...

Hi! This pull request follows from this issue https://github.com/scopsy/await-to-js/issues/14 ```Typescript const [error, response] = await to(myApiCall()); // expect response as ResponseDTO, receive ResponseDTO | undefined ```

# Problem Currently [example usage](https://github.com/scopsy/await-to-js#typescript-usage) (written for CommonJS modules) doesn't work for ES modules (aka ESM where application has `"type": "module"` in `package.json`), because default exports don't play nice with...