Created
April 12, 2019 17:45
-
-
Save grant/be5b6f12589dee8be1cefe5db591a7b5 to your computer and use it in GitHub Desktop.
BTC API – GCF
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
const rp = require('request-promise'); | |
const DEFAULT_DATE = '2019-04-10'; | |
exports.btc = async (req, res) => { | |
const date = req.query.date || DEFAULT_DATE; | |
async function getBTC(date) { | |
const res = await rp(`https://api.coinbase.com/v2/prices/BTC-USD/spot?date=${date}`, { | |
headers: { | |
'CB-VERSION': '2016-10-10', | |
Authorization: `Bearer ${process.env.COINBASE_TOKEN}` | |
} | |
}); | |
return res; | |
} | |
const btc = await getBTC(date); | |
res.send(btc); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment