Gravatar Utils
This npm package makes working with Gravatar a breeze. You don't need to worry about hashing emails, just use this package.
To import:
;
const userEmail = "xxxxxxxx@xxxxx.xxx"; // This function will generate the hash that gravatar uses to identify users, will return something similar to xxxxxxxxxxxxxxxxxxxxxconst userHash = ;// This function will generate the url that is accessible by any fetch library, will return something similar to https://www.gravatar.com/xxxxxxxxxxxxxxxxxxxxx.jsonconst gravatarProfileUrl = ; // Fetch gravatar profile with any libraryconst data = await ; // To get an image url for an avatar, use the getGravatarAvatar function. You can optionally specify the size in an object in the second function parameter.<img src= />
To install:
npm install gravatar-utils
More information on the Gravatar API can be found at https://www.gravatar.com/site/implement/profiles/json/.
Type definitions are provided!