I'm just trying to store some value using rest API.
[{"userID":1,"passwordHash":"asdasd","email":"[email protected]"},{"userID":2,"passwordHash":"12345","email":"[email protected]"}]
This is what my data looks like.
I'm using Spring boot on the server side on windows machine. To post value I'm using this in the console :
curl -X POST -H "Content-Type: application/json" -d "{ \"email\": \"aszzzzzzzzzzd\", \"passwordHash\": \"sad\" }" http://localhost:8080/user
Now I'm trying to POST from my react.js application. So I'm using XMLHttpRequest()
Here is the code on my react.js application :
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:8080/user');
xhr.send(JSON.stringify({ email: this.state.email,passwordHash:this.state.password }));
I've added @CrossOrigin(origins = "http://localhost:3000") to receive requests from my app.
But the problem is, it gives me an error saying :
POST http://localhost:8080/user 415
