-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95b2774
commit 1600f8c
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { isAddress } from '@ethersproject/address'; | ||
|
||
const EFP_API_URL = 'https://api.ethfollow.xyz'; | ||
|
||
export async function getUserStats( | ||
addressOrENS: string | ||
): Promise<{ followers_count: number; following_count: number }> { | ||
if (!isAddress(addressOrENS)) return Promise.reject('Invalid address'); | ||
|
||
const res = await fetch(`${EFP_API_URL}/api/v1/users/${addressOrENS}/stats`); | ||
const stats = await res.json(); | ||
|
||
return { | ||
followers_count: parseInt(stats.followers_count), | ||
following_count: parseInt(stats.following_count) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters