K
K
Konstantin_P2019-12-15 15:12:06
JavaScript
Konstantin_P, 2019-12-15 15:12:06

What is the correct way to send a file from a node.js server and save it in the browser?

What is the correct way to send a file from a node.js server and save it in the browser? Is it possible via fetch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IDONTSUDO, 2019-12-16
@IDONTSUDO

1. Take Express app.use(express.static([directory name where files will be saved]));
2. We take multer and with it we organize the delivery of files to the server
3. We take HTML and use it to download files
If you used Express, then your static files are available in this way.
localhost:3000/images/bg.png
(as an example)
It turns out to download the file. You must paste this path into the HTML.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question