mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
datahandler
This commit is contained in:
parent
18242ba058
commit
eb5487385e
1 changed files with 14 additions and 10 deletions
|
@ -12,18 +12,22 @@ import profilePic from "public/profile.webp";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const [spotify, setSpotify] = useState<any>("nothing");
|
const [spotify, setSpotify] = useState<any>("");
|
||||||
|
|
||||||
|
const handleData = () => {
|
||||||
|
fetch("/api/spotify")
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => setSpotify(data));
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
handleData();
|
||||||
fetch("/api/spotify")
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((data) => {
|
|
||||||
setSpotify(data);
|
|
||||||
});
|
|
||||||
}, 9999);
|
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => {
|
||||||
|
setInterval(() => {
|
||||||
|
handleData();
|
||||||
|
}, 3000);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -61,7 +65,7 @@ export default function () {
|
||||||
<Link href={`${spotify.song.url}`}>
|
<Link href={`${spotify.song.url}`}>
|
||||||
<a target="_blank" className="text-[#32a866]">
|
<a target="_blank" className="text-[#32a866]">
|
||||||
{" "}
|
{" "}
|
||||||
{spotify.song.title || "nothing"}
|
{spotify.song.title}
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue