Skip to content

Instantly share code, notes, and snippets.

@adilcpm
Last active July 17, 2024 11:19
Show Gist options
  • Save adilcpm/cea98ae5525ed9b535dd210ca3fae637 to your computer and use it in GitHub Desktop.
Save adilcpm/cea98ae5525ed9b535dd210ca3fae637 to your computer and use it in GitHub Desktop.
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