April 2020
Intermediate to advanced
716 pages
18h 55m
English
On the server, to process the request to the update API that may now contain a file, we will use the formidable Node module. Run the following command from the command line to install formidable:
yarn add formidable
The formidable will allow the server to read the multipart form data and give us access to the fields and the file, if there are any. If there is a file, formidable will store it temporarily in the filesystem. We will read it from the filesystem using the fs module, which will retrieve the file type and data, and store it in the photo field in the user model. The formidable code will go in the update controller in user.controller.js, as follows.
mern-social/server/controllers/user.controller.js ...
Read now
Unlock full access