added refresh token
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState, useCallback } from "react";
|
||||
import { API_URL } from "../config/authConstants";
|
||||
import { apiFetch } from "../api/apiClient";
|
||||
|
||||
export function useDeleteChat() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -9,12 +10,8 @@ export function useDeleteChat() {
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const token = localStorage.getItem("token");
|
||||
const res = await fetch(`${API_URL}/api/v1/chats/${chatId}`, {
|
||||
const res = await apiFetch(`${API_URL}/api/v1/chats/${chatId}`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
},
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(`Ошибка ${res.status}`);
|
||||
@@ -29,4 +26,4 @@ export function useDeleteChat() {
|
||||
}, []);
|
||||
|
||||
return { deleteChat, loading, error };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user