# try_catch_req

> A module to make clear and succinct a redundant async/await try-catchs in using promises in node routes.

Latest version **1.0.0** (published 2021-10-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install try_catch_req
pnpm add try_catch_req
yarn add try_catch_req
bun add try_catch_req
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-10-21 |
| First published | 2021-10-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Amare Abewa |
| Maintainers | amareabewa |
| Keywords | async/await, try-catch, promise, then, callback |

## Links

- npm: https://www.npmjs.com/package/try_catch_req
- Repository: https://github.com/amareabewachanie/try-catch
- Homepage: https://github.com/amareabewachanie/try-catch#readme
- Issues: https://github.com/amareabewachanie/try-catch/issues
- npm.io page: https://npm.io/package/try_catch_req

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2021-10-21

## README

# try-catch
 handling callbacks with async/await on node js server req,res pipeline without managing
  ```node
  try{ 
  // the progrm that will cause exception 
  }catch(){
  // handling when the exception has happened
  }
  ```
Just wrape your req,res pipeline with a tryCatch method by importing from this library, then it handles the rest.
# Install the dependency
```sh
npm install try_catch_req
```
 # Example
 
```node
const express=require('express');
const tryCatch=require('./index')
const app=express();

app.use(express.json())
app.post('/test',tryCatch(async(req,res,next)=>{
    const {name,job}=req.body;
    // you can call any async functions with await keyword,
    // Incase if exception throws that function the library handles automatically.
    res.status(201).json({message :`Well come ${name}, Are you really a ${job}?`})}));
module.exports=app;
```

---
_Source: https://npm.io/package/try_catch_req · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
