Skip to content

Instantly share code, notes, and snippets.

@zefhemel
Last active April 6, 2021 14:52
Show Gist options
  • Save zefhemel/cdfddf3276524dc2cf18b9d133734e83 to your computer and use it in GitHub Desktop.
Save zefhemel/cdfddf3276524dc2cf18b9d133734e83 to your computer and use it in GitHub Desktop.
Focalboard Deno API
export class Focalboard {
constructor(url, token, workspaceId) {
this.url = url;
this.token = token;
this.workspaceId = workspaceId;
}
async allBlocks() {
let result = await fetch(`${this.url}/api/v1/workspaces/${this.workspaceId}/blocks?type=view`, {
headers: {
"accept": "application/json",
"authorization": `Bearer ${this.token}`,
"x-requested-with": "XMLHttpRequest"
},
"method": "GET",
});
return await result.json();
}
async addBlock(blocks) {
let result = fetch(`${this.url}/api/v1/workspaces/${this.workspaceId}/blocks`, {
"headers": {
"accept": "application/json",
"authorization": `Bearer ${this.token}`,
"content-type": "application/json",
"x-requested-with": "XMLHttpRequest"
},
"body": JSON.stringify(blocks),
"method": "POST",
});
return await result.json();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment