An open API service indexing awesome lists of open source software.

https://github.com/qwyzex/firerr

Firebase Error Catching
https://github.com/qwyzex/firerr

firebase

Last synced: 1 day ago
JSON representation

Firebase Error Catching

Awesome Lists containing this project

README

          

# FirErr

FirErr is a package for catching Firebase Errors that often occurs. Firebase can only send one response at a time, so catching it _one-by-one_ is not that bad, I think.

## 🤔 Usage

You can use it by defining a state, or variables that store the Firebase Error Message :

```
import { useState } from "react";

const [formError, setFormError] = useState("");
```

Then do some 🔥 Firebase Stuff :

```js
async function login(e) {
e.preventDefault();
await createUserWithEmailAndPassword(auth, formEmail, formPassword)
.then(() => {
// finish
})
.catch((error) => {
const code = error.code;
firerr(code, formError);
});
}
```

## `firerrString()` function

```js
import { firerrString } from "firerr";

async function login(e) {
e.preventDefault();
await createUserWithEmailAndPassword(auth, formEmail, formPassword)
.then(() => {
// finish
})
.catch((error) => {
const code = error.code;
alert(firerrString(code));
});
}
```

> 🥶 Idk who install this package tho...
> This is my very first NPM Package.
> I am very sorry if there's a problem! I'm only 14 yo, 15 next September 🤧
>
> \- qwyzex, 2022