first version of data fetcher
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
"use client";
|
||||
import { getUser } from "muzak/data/fetch";
|
||||
import { useEffect, useState } from "react";
|
||||
import api from "muzak/data/fetcher";
|
||||
|
||||
export default function Page() {
|
||||
const [userData, setUserData] = useState<User[]>([]);
|
||||
const [userData, setUserData] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
async function getUsers() {
|
||||
const user = getUser();
|
||||
const access_token = user?.access_token;
|
||||
const headers = new Headers();
|
||||
headers.set("Authorization", `Bearer ${access_token}`);
|
||||
headers.set("Content-Type", "application/json; charset=utf-8");
|
||||
const users = await fetch("http://127.0.0.1:8001/api/user/", { headers });
|
||||
const userData = await users.json();
|
||||
setUserData(userData);
|
||||
const { data: users } = await api.users.list({});
|
||||
setUserData(users);
|
||||
}
|
||||
getUsers();
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user