Created
July 15, 2018 13:06
-
-
Save Jerga99/ce8972abfe1a0408e376df20d88f87ec 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 upload = require('../services/multer'); | |
const singleUpload = upload.single('image') | |
router.post('/image-upload', function(req, res) { | |
singleUpload(req, res, function(err, some) { | |
if (err) { | |
return res.status(422).send({errors: [{title: 'Image Upload Error', detail: err.message}] }); | |
} | |
return res.json({'imageUrl': req.file.location}); | |
}); | |
}) | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment