How to get a file stored with nodejs and multer?

Asked

Viewed 60 times

0

In the API, in Nodejs, which I’m doing, the user sends the image to the API and, using multer, the image is stored. All the tutorials I saw for this situation, the Node is using a Preprocessor like jade, ejs, handlebars etc. But in my case, the front is done in Vuejs. So, how do I make the API "show" the searched image? If I try to access localhost:3000/api/company/public/minha-imagem.jgp the following error appears Cannot GET /api/company/public/minha-imagem.jpg.

  • You want to show an image the client sends or will send to the server, is that it? and why not do everything on the client side to send to the server and then back?

  • This image is the image of the product. I have no way to store the image on the front, and its name also needs to be saved in the bank. Hence the need to send to the server.

1 answer

0

Solution. In my app.js, i inserted app.use('/dist', express.static(path.join(__dirname + '/dist')));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.