Using Multer to Upload Photos for Node and React
February 28, 2021
This month, I learned to used Multer for a react project that I've been working on. It took me close to 6 days to get both the back-end and front end to work for Multer. There were times when I really struggled but in the end, I didn't give up and it's so rewarding to finally figured it out. Being able to upload a file successfully, especially a photo, and have it save to the database was something I was thinking about learning to do since December.
Many of the errors I had at the beginning were mainly missing the little stuff, like forgetting to deploy the latest changes to my server or having a syntax error.
Here are three resources that I've found really useful for my first implementation with Multer:
It took some heavy studying for me to finally get it to work but now I can use Multer for all of my future projects that require file uploading from now on
Note:
Remember to use axios to call to Multer, not fetch.
Many of the errors I had at the beginning were mainly missing the little stuff, like forgetting to deploy the latest changes to my server or having a syntax error.
Here are three resources that I've found really useful for my first implementation with Multer:
- https://blog.stvmlbrn.com/2017/12/17/upload-files-using-react-to-node-express-server.html (Setting up back-end and front-end)
- https://www.npmjs.com/package/multer-js (main documentation for node using Multer) (Main Doc)
- https://www.youtube.com/watch?v=srPXMt1Q0nY (Video on setting up on the back-end)
It took some heavy studying for me to finally get it to work but now I can use Multer for all of my future projects that require file uploading from now on
Note:
Remember to use axios to call to Multer, not fetch.
Posted by Ninja Space Content. Posted In : node
I had an interview with one of the big six companies earlier today. When I say 'big six', I'm referring to one of the following: Amazon, Facebook, Google, Netflix, Apple or Microsoft. I'm not going to tell you which one because I signed an NDA and I want to go further and don't want to jinx anything by telling you the exact one. I'll let you guess!
I have been building simple websites on my own since 2008 and currently run several websites at the moment, including this one. I used to be an account manager for an affiliate/e-commerce company, helping affiliates grow their sales so I have some knowledge on the business side and client side of affiliate marketing. During the Covid-19 pandemic, I completed a JavaScript coding bootcamp and graduated in Dec 2020. I've been working as a contractor for a few software companies ever since.