const updatedDates = [];
const token = await getGoogleAuthToken(env.EMAIL, env.PRIVATE_KEY, 'https://www.googleapis.com/auth/spreadsheets.readonly https://www.googleapis.com/auth/documents.readonly');
const sheetUrl = 'https://sheets.googleapis.com/v4/spreadsheets/1pfGF8yBu3D0GPTezygLuzu3Cif8SkjhtG98nL-czlhc/values/B3:I';
- await fetch(sheetUrl, { headers: { Authorization: `Bearer ${token}` } })
- .then(r => r.json())
- .then(googleSheet => {
- for (const article of googleSheet.values) {
- entries.push(`<entry>
+ const googleSheet = await fetch(sheetUrl, { headers: { Authorization: `Bearer ${token}` } }).then(r => r.json());
+ for (const article of googleSheet.values) {
+ entries.push(`<entry>
<id>urn:google:${article[2]}</id>
<title>${article[0]}</title>
${article[7].split(',').map(s => `<category term="${s.trim()}"/>`).join('')}
<published>${new Date(article[5]).toISOString()}</published>
<updated>${new Date(article[6]).toISOString()}</updated>
</entry>`);
- updatedDates.push(new Date(article[6]));
- }
- });
+ updatedDates.push(new Date(article[6]));
+ }
const feed = `<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">