Adding media fetch endpoint; working query with hardcoded incident

This commit is contained in:
efarooqui
2021-06-08 18:46:33 -07:00
parent 71a8687003
commit 66d7d42497

View File

@@ -1,4 +1,5 @@
import { version } from '../../package.json'
import fetch from 'node-fetch'
import { Router } from 'express'
import copy from '../copy/en'
@@ -22,6 +23,18 @@ export default ({ config, controller }) => {
})
})
api.get('/media', (req, res) => {
fetch(`${process.env.MEDIA_API_ENDPOINT}/cv_a12`, {
method: 'get',
headers: {
'Authorization': 'Basic ' + new Buffer(process.env.MEDIA_AUTH_USER + ":" + process.env.MEDIA_AUTH_PWORD).toString("base64")
}
})
.then(response => response.json())
.then(data => res.send(data.data))
.catch(err => res.status(err.status || 404).send({ error: err.message }));
})
api.get('/update', (req, res) => {
controller
.update()