mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
add try catch on credit api
This commit is contained in:
@@ -11,8 +11,13 @@ export default function CreditButton() {
|
||||
const [credit, setCredit] = useState<number | null>(null);
|
||||
|
||||
const fetchCredit = useCallback(async () => {
|
||||
const response = await api.getUserCredit();
|
||||
setCredit(response.credits);
|
||||
try {
|
||||
const response = await api.getUserCredit();
|
||||
setCredit(response.credits);
|
||||
} catch (error) {
|
||||
console.error("Error fetching credit:", error);
|
||||
setCredit(null);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user