kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
fix handleResponse function
rodzic
b5e142fb79
commit
5ed2edb125
|
@ -9,15 +9,19 @@ const useModerationPolicies = () => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const handleResponse = async (response: MastodonResponse, message: string) => {
|
const handleResponse = async (response: MastodonResponse, message: string) => {
|
||||||
const details = await response.error()
|
if (!response.ok) {
|
||||||
.then(v => v?.error || 'Unknown error');
|
const details = await response.error()
|
||||||
if (!response.ok) throw new Error(`${message}: ${details}`);
|
.then(v => v?.error || 'Unknown error');
|
||||||
|
throw new Error(`${message}: ${details}`);
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
// Check if the response contains an error
|
// Check if the response contains an error
|
||||||
if (data && 'error' in data) throw new Error(data.error);
|
if (data && 'error' in data) throw new Error(data.error);
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const allPoliciesQuery = useQuery({
|
const allPoliciesQuery = useQuery({
|
||||||
queryKey: ['admin', 'moderation_policies'],
|
queryKey: ['admin', 'moderation_policies'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
|
Ładowanie…
Reference in New Issue