I’m building a user sign-up feature using React with Axios to connect to my PHP backend. My form submission isn’t targeting the correct endpoints. What adjustments should I make?
function registerUser(evt) {
evt.preventDefault();
const payload = new FormData();
payload.append('userEmail', this.state.input.email);
payload.append('userPwd', this.state.input.password);
payload.append('userName', this.state.input.name);
payload.append('bizName', this.state.input.company);
payload.append('userRegion', this.state.input.region);
axios
.post('http://dev.example.com/register', payload)
.then(response => {
if (response.data) {
console.log('Registration succeeded');
this.props.history.push('/dashboard');
}
})
.catch(error => console.error(error));
}