Skip to content

Instantly share code, notes, and snippets.

@danielberndt
Last active October 24, 2022 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielberndt/1f17f8864532a2a1e9ca3761aac986c2 to your computer and use it in GitHub Desktop.
Save danielberndt/1f17f8864532a2a1e9ca3761aac986c2 to your computer and use it in GitHub Desktop.
extract all cards via api
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