We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7e234b4 commit 6748a73Copy full SHA for 6748a73
src/lib/extractNamesFromJson.ts
@@ -0,0 +1,19 @@
1
+// The reason for these interfaces is so that typescript neatly throws an error when a user
2
+// adds a json that is not a followers.json or following.json format
3
+
4
+interface ExpectedJSON {
5
+ title: string;
6
+ media_list_data: unknown[];
7
+ string_list_data: stringListData[];
8
+}
9
10
+interface stringListData{
11
+ href: string;
12
+ value: string;
13
+ timestamp: number;
14
15
16
+export default function ExtractNamesFromJson(json: ExpectedJSON[]) {
17
+ const usernames = json.map(user => user.string_list_data[0].value);
18
+ return usernames;
19
0 commit comments