Avatar API Fetcher
How to Fetch with X-Avatar-Key
- First, obtain your API key from the avatar service provider
- Include the X-Avatar-Key in your request headers
- Make a GET request to the API endpoint
- Process the response data
Example Code
async function fetchAvatarData(apiKey) {
const response = await fetch('https://api.avatar-service.com/v1/avatar', {
headers: {
'X-Avatar-Key': apiKey,
'Content-Type': 'application/json'
}
});
if (!response.ok) throw new Error('Failed to fetch');
return await response.json();
}