fixed name and headers

This commit is contained in:
2026-03-02 18:38:14 -06:00
parent 32bbfe107f
commit 1de700902a
4 changed files with 23 additions and 8 deletions
@@ -2,6 +2,7 @@
import { useEffect, useState } from "react";
import axios from "axios";
import Cookies from "js-cookie";
interface SearchUserProps {
value?: string | null;
@@ -19,7 +20,9 @@ export default function SearchUserTable({ value }: SearchUserProps) {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
// Si el prop cambia, actualizar el input
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
useEffect(() => {
if (value) setNumAcount(value);
}, [value]);
@@ -37,8 +40,8 @@ export default function SearchUserTable({ value }: SearchUserProps) {
setAlumno(null);
try {
// Llamada a la API con Axios
const { data } = await axios.get<Alumno>(`/api/alumnos/${numAcount}`);
const { data } = await axios.get<Alumno>(`/api/alumnos/${numAcount}`, { headers },
);
setAlumno(data);
} catch (err: any) {
setAlumno(null);