Handle your await/async promises safely without try/catch blocks.
npm
npm i @kearash/safe
pnpm
pnpm add @kearash/safe
bun
bun i @kearash/safe
yarn
yarn add @kearash/safe
import { safe } from '@kearash/safe';
const fetchData = async () => {
const [error, data] = await safe(fetch('https://jsonplaceholder.typicode.com/'));
if (error) {
console.error('Error fetching data:', error);
return;
}
console.log('Fetched data:', data);
};
fetchData();
This project is licensed under the MIT License. See the LICENSE file for details.