Sunday 28 April 2019

How to send post request with react server to express server with axios?

I have a client/react (port 3000) server and an express (port 3001) server. I am sending a post request with axiosaxios.post('http://localhost:3001/test', this.state.appointments); to the express serverrouter.post('/test', function(req, res) { console.log(req); res.send("Worked!!!"); }); I get this error when I do it:Access to XMLHttpRequest at 'http://localhost:3001/test' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Submitted April 28, 2019 at 05:17PM by AmirSaran

No comments:

Post a Comment