postLocation.js
580 Bytes
const createError = require('http-errors')
const su = require('superagent')
const dbhost = process.env.COUCHDB_URL
const dbubicaciones = process.env.DB_UBICACIONES
const headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
const postLocation = (payload) =>
su.post(`${dbhost}/${dbubicaciones}/`)
.set(headers)
.send(JSON.stringify(payload))
module.exports = (req, res, next) => {
postLocation(req.body)
.then(() => res.json({ success: true, error: false }))
.catch(error => next(createError(500, error, { expose: true })))
}