I want to send the image from the react form to the nodeJs but I am facing problem like "500 (Internal Server Error)"
I want to send the formData from react to node but facing problem
this is my backend/app/controllers/controller.book.js
I created backend/app/helpers/fileUploaderHelper.js
I have created frontend/src/admin/book/Create.jsx
frontend/src/api/request.api.js
frontend/src/api/http.api.js
I tried above code but to different files structure I facing difficulty
Related
Im trying to download a pdf file stored in mongodb using gridfs andmulter , I am recieving a stream back which when I downloaded and open the pdf file would be corrupted here is my backend for downloading it [My backend is node js and frontend is react js ].
here is my backend code
here is my frontend code
here is the response that i recieved
this is what the response.data would look like
lastly this is what the error looks like when I opened one of those downloaded files
please do help me out ive been struggling in the past two days to find a solution to this
I am working on a project which has an upload file feature. The text data from this file is to be send to the backend Node js server through axios post request and then uploaded to the database.
While using a smaller file (around 4 kb), it is working fine. But when I upload a large sized file (~10000 kb), I am getting two error simultaneously.
CORS error at the client side (React Js).
PayloadTooLargeError at the server side (Node Js).
I tried using the soluyion given in the post: Error: request entity too large, but it is not working.
so i am using react js as my front-end framework and node and express js for my back end .
i used axios to send data from my react app to my back end server but am not able to receive the data at my server end.
my react js code to send data
function handelClick(event){
event.preventDefault();
console.log(data);
axios.post("http://localhost:9000/login",data)
.then(response=>console.log(response))
.catch(err=>console.log(err));
}
my node js server side code to receive data
app.post('/login',(req,res)=>{console.log(req);});
i thought i could find the sent data inside req object but i don't see it .
am new so any help is much appreciated.
Have you imported axios in reactjs file? Or you can try to check in package.json of reactjs app had:
"proxy": "http://127.0.0.1:5000" //port running on your server
i'm having some problems creating an object + uploading an image at the same API call. the server was created by be (Node.js + mongoDB). its a POST that used multer to extract all data (form - data) and all tests using postman seems to be working fine.
i'm using Alamofire in my IOS app
post with content type
upload and multi form data
my server code
I'm having a backend nodejs server and a frontend angular web applicantion both are in different folders and running on different ports (Nodejs server: 8000 and angular client:4200). I'm storing images on nodejs server's directory in "uploads folder" using api and then storing the image path in the database. Then retrieving the image path using api to display it. I'm getting the image path like this (http://localhost:8000/uploads/030312-1618.jpg) but the image is not displaying.
Assuming that you are using ExpressJS, have you set up the serving of static files as follows.
app.use(express.static('uploads'))
Source : http://expressjs.com/en/starter/static-files.html
(Can help you further if you add more details such as any errors that you get, more information about the tech stack you use, etc.)