Skip to content

davidohlin/await-to-fetch

Repository files navigation

await-to-fetch Build Status

Easy error handling for async/await without try/catch blocks that works with fetch.

Install

$ npm install await-to-fetch

Usage

import to from 'await-to-fetch'

async function example() {
  const [err, res] = await to(fetch('https://httpstat.us/200'))

  if (err) {
    throw err
  }

  return res
}

Credits

About

⏱ Easy error handling for async/await fetch requests without try/catch

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •