Await To Js

Async await wrapper for easy error handling without try-catch
Alternatives To Await To Js
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Await To Js2,476644275a year ago7March 09, 20217mitTypeScript
Async await wrapper for easy error handling without try-catch
Await Result11123 years ago17February 24, 20201mitTypeScript
Error handling for async functions without try/catch blocks
Asyncawait Typescript Example2
8 years agoHTML
Netlify Cog2
7 years agoapache-2.0JavaScript
A cog to use with Operable to manage Netlify sites.
Errisy Tsc1
6 years agoJavaScript
a customized typescript compiler transpiler
Express Mongoose Api Es6 Example1
5 years agomitJavaScript
This is a simple starter project example using express, mongoose with es6 code without any transpiler.
Atom Js Transpiler1
9 years agoPython
Alternatives To Await To Js
Select To Compare

Alternative Project Comparisons


NPM version Downloads

Async await wrapper for easy error handling

Supported by:
The open-source notification infrastructure


You need to use Node 7.6 (or later) or an ES7 transpiler in order to use async/await functionality. You can use babel or typescript for that.


npm i await-to-js --save


import to from 'await-to-js';
// If you use CommonJS (i.e NodeJS environment), it should be:
// const to = require('await-to-js').default;

async function asyncTaskWithCb(cb) {
     let err, user, savedTask, notification;

     [ err, user ] = await to(UserModel.findById(1));
     if(!user) return cb('No user found');

     [ err, savedTask ] = await to(TaskModel({userId:, name: 'Demo Task'}));
     if(err) return cb('Error occurred while saving task');

    if(user.notificationsEnabled) {
       [ err ] = await to(NotificationService.sendNotification(, 'Task Created'));
       if(err) return cb('Error while sending notification');

    if( !== {
       [ err, notification ] = await to(NotificationService.sendNotification(, 'Task was created for you'));
       if(err) return cb('Error while sending notification');

    cb(null, savedTask);

async function asyncFunctionWithThrow() {
  const [err, user] = await to(UserModel.findById(1));
  if (!user) throw new Error('User not found');

TypeScript usage

interface ServerResponse {
  test: number;

const p = Promise.resolve({test: 123});

const [err, data] = await to<ServerResponse>(p);


MIT © Dima Grossman && Tomer Barnea

Popular Async Await Projects
Popular Transpiler Projects
Popular Control Flow Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.