diff --git a/utils.js b/utils.js index bb76488..2e783a8 100644 --- a/utils.js +++ b/utils.js @@ -252,8 +252,14 @@ export async function getTraktMovie(config) { // ======================================================================== // hardcover graphql api - grabs your currently reading book +// requires HARDCOVER_API_KEY see readme for more info export async function getHardcoverActivity(config) { const { userId, feedUrl } = config + const apiKey = process.env.HARDCOVER_API_KEY + if (!apiKey) { + throw new Error('HARDCOVER_API_KEY environment variable not set') + } + const query = ` query { user(username: "${userId}") { @@ -267,7 +273,10 @@ export async function getHardcoverActivity(config) { const res = await fetch(feedUrl, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { + 'Content-Type': 'application/json', + authorization: apiKey, + }, body: JSON.stringify({ query }), })