Fetch someone follow list from Foundation
January 11th, 2022
const ADDRESS = '0x...' // Change this ADDRESS
fetch(
  'https://hasura2.foundation.app/v1/graphql', {
  'referrer': 'https://foundation.app/',
  'referrerPolicy': 'strict-origin-when-cross-origin',
  'body': JSON.stringify({
      'query': `
          query UserFollowing($publicKey: String!, $currentUserPublicKey: String!, $offset: Int!, $limit: Int!) {
        user: user_by_pk(publicKey: $publicKey) {
          following(where: {isFollowing: {_eq: true}}, offset: $offset, limit: $limit) {
            user: userByFollowedUser {
              name
              username
              publicKey
              profileImageUrl
              isFollowingUser: follows_aggregate(
                where: {user: {_eq: $currentUserPublicKey}, isFollowing: {_eq: true}}
              ) {
                aggregate {
                  count
                }
              }
            }
          }
        }
      }
    `,
    'variables': {
        'publicKey': ADDRESS,
        'currentUserPublicKey': ADDRESS,
        'limit': 42069,
        'offset': 0
    }
  }),
  'method': 'POST',
  'mode': 'cors',
  'credentials': 'omit'
})
  .then(response => response.json())
  .then(
    ({
      data: {
        user: {
          following = []
        }
      }
    }) => {
      const result = following
        .map(({
          user: {
            name,
            username,
            publicKey,
            profileImageUrl
          }
        }) => `${publicKey}\t${name}\t${username}\t${profileImageUrl}`)
        .join("\n");
      console.log(result);
    }
  );

πŸ‘‡

0x...	Name 1	username1	https://...png
0x...	Name 2	username2	https://...jpg

πŸ‘Œ

Subscribe to ranbuta
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from ranbuta

Skeleton

Skeleton

Skeleton