Last active
October 24, 2022 11:54
-
-
Save danielberndt/1f17f8864532a2a1e9ca3761aac986c2 to your computer and use it in GitHub Desktop.
extract all cards via api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let subdomain = "MYSUBDOMAIN"; // for e.g. MYSUBDOMAIN.codecks.io | |
let cardQuery = {cardCreatedAt: {op: "gt", value: "2022-10-20"}}; | |
// build up the nested query and define which models and fields we want to receive | |
let query = { | |
_root: [ | |
{ | |
account: [ | |
{ | |
[`cards(${JSON.stringify(cardQuery)})`]: [ | |
"title", | |
"content", | |
{attachments: [ | |
"title", | |
{file: ["url"]} | |
]} | |
], | |
}, | |
], | |
}, | |
], | |
}; | |
// pass the query to the api | |
let data = await fetch(`https://api.codecks.io?query=${JSON.stringify(query)}&x-account=${subdomain}`, {credentials: "include"}).then(r => r.json()) | |
console.log(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment