Last active
October 4, 2019 16:44
-
-
Save mfsiat/a4c08bfb4cae18eef1f005ebc9bcd62a to your computer and use it in GitHub Desktop.
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 express = require('express'); | |
const router = express.Router(); | |
const fetch = require('node-fetch'); | |
router.get('/:platform/:platformUserIdentifier', async (req, res) => { | |
try { | |
const headers = { | |
'TRN-Api-Key': process.env.TRACKER_API_KEY | |
}; | |
const { platform, platformUserIdentifier } = req.params; | |
const response = await fetch( | |
`${process.env.TRACKER_API_URL}/profile/${platform}/${platformUserIdentifier}`, | |
{ | |
headers | |
} | |
); | |
const data = await response.json(); | |
res.json(data); | |
} catch (err) { | |
console.error(err); | |
res.status(500).json({ | |
message: "Error" | |
}); | |
} | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment