Last active
October 2, 2019 19:29
-
-
Save bbarreto/bc97ff448eeab2c6d02614766bf322eb to your computer and use it in GitHub Desktop.
Spelpaus Blocking Info
This file contains hidden or 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 http = require('http'); | |
const axios = require('axios'); | |
const router = express.Router(); | |
const app = express(); | |
app.use(router); | |
const spelpausConfig = { | |
URL: 'https://testapi.spelpaus.se/api/blocking-info/22', | |
token: 'suPei2qGuxEVX0U5t8Xr5MHTbRWJrbKJLEZTPD21mLhSca0a7qGtnkvPyEEf', | |
}; | |
router.get('/', (req, res) => { | |
axios({ | |
method: 'post', | |
url: spelpausConfig.URL, | |
data: { | |
requestId: new Date().getTime(), | |
subjectId: req.query.subjectId, | |
}, | |
headers: { | |
Accept: 'application/json; charset=utf-8', | |
'Content-Type': 'application/json; charset=utf-8', | |
Authorization: spelpausConfig.token, | |
}, | |
}) | |
.then(response => { | |
res.send(response.data); | |
}) | |
.catch(err => { | |
res.status(err.response.status).send(err.response.data); | |
}); | |
}); | |
http.createServer(app).listen(9595); |
This file contains hidden or 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
{ | |
"name": "spelpaus-blocking-info", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Bruno Barreto <[email protected]>", | |
"license": "ISC", | |
"dependencies": { | |
"axios": "^0.19.0", | |
"express": "^4.17.1", | |
"http": "0.0.0", | |
"request": "^2.88.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment