Avatar API Fetcher

How to Fetch with X-Avatar-Key

  1. First, obtain your API key from the avatar service provider
  2. Include the X-Avatar-Key in your request headers
  3. Make a GET request to the API endpoint
  4. 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();
}