mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-30 06:41:59 +08:00

### What problem does this PR solve? Unified API response json schema ### Type of change - [x] Refactoring
19 lines
447 B
TypeScript
19 lines
447 B
TypeScript
import axios from 'axios';
|
|
import { useCallback, useEffect, useState } from 'react';
|
|
|
|
export const useCatchDocumentError = (url: string) => {
|
|
const [error, setError] = useState<string>('');
|
|
|
|
const fetchDocument = useCallback(async () => {
|
|
const { data } = await axios.get(url);
|
|
if (data.code !== 0) {
|
|
setError(data?.message);
|
|
}
|
|
}, [url]);
|
|
useEffect(() => {
|
|
fetchDocument();
|
|
}, [fetchDocument]);
|
|
|
|
return error;
|
|
};
|