Skip to content

Instantly share code, notes, and snippets.

@mfsiat
Last active October 4, 2019 16:44
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 mfsiat/a4c08bfb4cae18eef1f005ebc9bcd62a to your computer and use it in GitHub Desktop.
Save mfsiat/a4c08bfb4cae18eef1f005ebc9bcd62a to your computer and use it in GitHub Desktop.
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