Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to create an application using the Monzo Bank API
app.get('/accounts', (req, res) => {
const { token_type, access_token } = accessToken;
const accountsUrl = 'https://api.monzo.com/accounts';
request.get(accountsUrl, {
headers: {
Authorization: `${token_type} ${access_token}`
}
}, (req, response, body) => {
const { accounts } = JSON.parse(body);
res.type('html');
res.write('<h1>Accounts</h1><ul>');
for(let account of accounts) {
const {id, type, description } = account;
res.write(`
<li>
${description}(<i>${type}</i>) - <a href="/transactions/${id}">View transaction history</a>
</li>
`);
}
res.end('</ul>');
});
});
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.