Wednesday, 26 April 2017

How to display image in angular?

I uploaded image using multer,node.js,mongodb.

i uploded image in upload folder and i stored path in mongodb.

this is my folder structure

enter image description here

based on document id i am retriving document

// To get the single image/File using id from the MongoDB
app.get('/images/:id', function(req, res) {

//calling the function from index.js class using routes object..
routes.getImageById(req.params.id, function(err, genres) {
if (err) {
throw err;
}
//res.download(genres.path);
res.send(genres)
});
});

i got response like this

{"_id":"590051dcc90cf702e452b9c1","path":"uploads\login.jpg","name":"asdf","email":"asdf@gmail.com","originalname":"login.jpg","__v":0}

i am sending the above response to angular and andriod application.

now i want to display this image in angular .help me out



via its me

No comments:

Post a Comment