* Processes a list of githubIds and adds avatar_base64 property * @param {Array} ids - Array of id * @returns {Promise } Array of avatar_base64
(ids)
| 90 | * @returns {Promise<Array>} Array of avatar_base64 |
| 91 | */ |
| 92 | async function processAvatars(ids) { |
| 93 | const processedArray = []; |
| 94 | |
| 95 | for (let i = 0; i < ids.length; i++) { |
| 96 | const _id = ids[i]; |
| 97 | |
| 98 | try { |
| 99 | console.log(`-- Fetching avatar for ${_id} ... [${i + 1}/${ids.length}]`); |
| 100 | |
| 101 | // Fetch avatar and convert to base64 |
| 102 | const avatarBase64 = await fetchAvatarAsBase64(_id); |
| 103 | |
| 104 | processedArray.push({ |
| 105 | id: _id, |
| 106 | avatar_base64: avatarBase64 |
| 107 | }); |
| 108 | console.log(`✓ Successfully processed ${_id}`); |
| 109 | } catch (error) { |
| 110 | console.error(`✗ Error processing ${_id}: ${error.message}`); |
| 111 | } |
| 112 | |
| 113 | // Add random delay between 100-2000 millisecond before next request (except for the last member) |
| 114 | if (i < ids.length - 1) { |
| 115 | await new Promise((resolve) => setTimeout(resolve, getRandomDelay(100, 2000))); |
| 116 | } |
| 117 | } |
| 118 | return processedArray; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Processes blog authors data and adds avatar_base64 property |
no test coverage detected