Last active
July 17, 2024 11:19
-
-
Save adilcpm/cea98ae5525ed9b535dd210ca3fae637 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 formattedTraitInfo: Array<{ traitType: string, traitValues: string[] }> = []; | |
// Assuming meAttributeData is the data output from ME API | |
meAttributeData?.results.availableAttributes.forEach(availableAttribute => { | |
const { trait_type: traitType, value } = availableAttribute.attribute; | |
const existingTrait = formattedTraitInfo.find(item => item.traitType === traitType); | |
if (existingTrait) { | |
existingTrait.traitValues.push(value); | |
} else { | |
formattedTraitInfo.push({ traitType, traitValues: [value] }); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment