-
-
Save avneesh0612/f9fa2da025fa764c6dc65de5f3d5ecec to your computer and use it in GitHub Desktop.
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
const fid1 = 194; | |
const fid2 = 191; | |
const url1 = `https://api.neynar.com/v2/farcaster/user/subscribed_to?fid=${fid1}&viewer_fid=3&subscription_provider=fabric_stp`; | |
const url2 = `https://api.neynar.com/v2/farcaster/user/subscribed_to?fid=${fid2}&viewer_fid=3&subscription_provider=fabric_stp`; | |
const fetchUrls = async () => { | |
const options = { | |
method: "GET", | |
headers: { accept: "application/json", api_key: "NEYNAR_API_DOCS" }, | |
}; | |
const response = await Promise.all([ | |
fetch(url1, options), | |
fetch(url2, options), | |
]); | |
const data = await Promise.all(response.map((res) => res.json())); | |
return data; | |
}; | |
fetchUrls().then((data) => { | |
const [subscribedTo1, subscribedTo2] = data; | |
const commonSubscriptions = subscribedTo1.subscribed_to.filter( | |
(item1: { contract_address: string }) => | |
subscribedTo2.subscribed_to.some( | |
(item2: { contract_address: string }) => | |
item2.contract_address === item1.contract_address | |
) | |
); | |
console.log(commonSubscriptions); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment