Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const fetch = require('node-fetch');
async function run() {
let username = "YOUR USERNAME HERE";
let password = "YOUR APP PASSWORD";
let authBasic = new Buffer(username + ':' + password).toString('base64');
let session = await (await fetch('https://jmap.fastmail.com/.well-known/jmap', {
headers: {
"Authorization": "Basic " + authBasic
}
})).json();
let accountId = session['primaryAccounts']['urn:ietf:params:jmap:mail'];
let query = {
"using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ],
"methodCalls": [[ "Mailbox/get", {
"accountId": accountId,
"ids": null
}, "0" ]]
}
let data = await (await fetch('https://jmap.fastmail.com/api/', {
method: 'POST',
headers: {
"Content-Type": "application/json",
"Authorization": "Basic " + authBasic
},
body: JSON.stringify(query)
})).json();
console.log(data.methodResponses[0][1])
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.