Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Last active March 11, 2018 17:00
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 graphicbeacon/cbddfdf92bc3aaf94e7a5ca28e7ebd8a to your computer and use it in GitHub Desktop.
Save graphicbeacon/cbddfdf92bc3aaf94e7a5ca28e7ebd8a to your computer and use it in GitHub Desktop.
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