// Custom function to encode a string to Base64 function base64Encode(str) { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; let encoded = '', i = 0;
while (i < str.length) { const a = str.charCodeAt(i++); const b = i < str.length ? str.charCodeAt(i++) : 0; const c = i < str.length ? str.charCodeAt(i++) : 0;
// Fetch API data with Basic Authentication try { const response = await fetch(apiUrl, { headers: { "Authorization": `Basic ${base64Credentials}` } });
// Check if the response was ok (status 200) if (response.ok) { const posts = await response.json; // Parse JSON response
// Check if there are posts if (posts.length > 0) { // Map each post title to a formatted string with bullet points const titles = posts.map(post => `• ${post.title.rendered} (${post.id})`).join('\n');