Last active
March 11, 2018 17:00
-
-
Save graphicbeacon/cbddfdf92bc3aaf94e7a5ca28e7ebd8a to your computer and use it in GitHub Desktop.
How to create an application using the Monzo Bank API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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