Skip to content

Commit 714bf1a

Browse files
committed
Next.js Client Components
1 parent 9d7a5a4 commit 714bf1a

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

app/connect/followers.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use client';
2+
3+
import { useState, useEffect } from 'react';
4+
5+
export default function Followers() {
6+
const [goalString, setGoalString] = useState('?/?');
7+
8+
useEffect(() => {
9+
fetch('https://spotify-api-wrapper.appspot.com/artist/david-kando')
10+
.then(response => response.json())
11+
.then(json => {
12+
console.log(`json`, json);
13+
14+
if (
15+
json
16+
&& json.artists
17+
&& json.artists.items
18+
&& json.artists.items.length > 0
19+
) {
20+
const followers = json.artists.items[0].followers.total;
21+
22+
setGoalString(`${followers}/?`);
23+
}
24+
})
25+
}, []);
26+
27+
return (
28+
<div className="ml-[15px] lg:ml-[20px] mt-[5px]">
29+
Follower progress: {goalString}
30+
</div>
31+
)
32+
}

app/connect/page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// import Form from './email-list/form';
2-
// import Followers from './followers';
2+
import Followers from './followers';
33

44
export default function Page() {
55
return (
@@ -20,7 +20,7 @@ export default function Page() {
2020
1. Support me with a follow on{' '}
2121
<a className="font-bold link" href="https://open.spotify.com/artist/6ep6Hvwexmaa5IqcPxMxqC?si=t24Vsf6LRsKSIy5lV0wvNw" target="_blank">Spotify</a>.
2222
</div>
23-
{/* <Followers /> */}
23+
<Followers />
2424
<br />
2525
<div>
2626
2. Follow me on{' '}

0 commit comments

Comments
 (0)