added new style and fixed send token
This commit is contained in:
+17
-3
@@ -1,11 +1,25 @@
|
||||
import axios from "axios";
|
||||
import { envConfig } from "./config";
|
||||
import apiClient from "./apiClient";
|
||||
import { redirect } from "next/navigation";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
if (!envConfig.apiUrl) {
|
||||
throw new Error("API URL is not defined in envConfig");
|
||||
}
|
||||
|
||||
export async function GetStudent(numAcount: number) {
|
||||
const cookieStore = cookies();
|
||||
const token = (await cookieStore).get("token")?.value;
|
||||
|
||||
if (!token) redirect("/");
|
||||
try {
|
||||
const response = await apiClient.get(
|
||||
`/student/${numAcount}`
|
||||
const response = await axios.get(
|
||||
`${envConfig.apiUrl}/student/${numAcount}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user