added hardcover activity function with API key validation
This commit is contained in:
parent
221e96b7c1
commit
936a8437b7
1 changed files with 10 additions and 1 deletions
11
utils.js
11
utils.js
|
|
@ -252,8 +252,14 @@ export async function getTraktMovie(config) {
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
|
||||||
// hardcover graphql api - grabs your currently reading book
|
// hardcover graphql api - grabs your currently reading book
|
||||||
|
// requires HARDCOVER_API_KEY see readme for more info
|
||||||
export async function getHardcoverActivity(config) {
|
export async function getHardcoverActivity(config) {
|
||||||
const { userId, feedUrl } = 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 = `
|
const query = `
|
||||||
query {
|
query {
|
||||||
user(username: "${userId}") {
|
user(username: "${userId}") {
|
||||||
|
|
@ -267,7 +273,10 @@ export async function getHardcoverActivity(config) {
|
||||||
|
|
||||||
const res = await fetch(feedUrl, {
|
const res = await fetch(feedUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
authorization: apiKey,
|
||||||
|
},
|
||||||
body: JSON.stringify({ query }),
|
body: JSON.stringify({ query }),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue