Я использую Express для создания api, и я использую angular для отправки запроса POST, по какой-то причине запрос не отправляется, и я не знаю почему.
сервер
app.post('/users/register', (req, res) => {
const { first_name, last_name, email, password, city, street } = req.body
pool.query('INSERT INTO users SET ? ', {first_name,last_name,email,password,city,street }, (err, data) => {
if(err) {
console.log(err);
} else {
console.log(data);
res.status(200).send(data)
}
})
})
сервис
insertUsers(registerFrom) {
return this.http.post('http://localhost:3000/users/register', registerFrom)
}
компонент TS
submitFrom(registerForm) {
console.log(registerForm);
this.appControl.insertUsers(registerForm)
.subscribe(data => {
console.log(data);
})
}
компонент html
<form #registerFrom="ngForm" (ngSubmit)="submitFrom(registerFrom.value)" class="form-container sign-up-container">
<div class="thisForm">
<h1>Create Account</h1>
<div >
<input type="checkbox" id="admin" name="admin" value="Admin">
<label for="admin"> Admin?</label>
</div>
<div class="social-container">
<span>or use your account</span>
</div>
<input ngModel name="name" type="text" placeholder="First name" />
<input ngModel name="lastName" type="text" placeholder="Last name" />
<input ngModel name="email" type="email" placeholder="Email" />
<input ngModel name="password" type="password" placeholder="Password" />
<div class="adress">
<input name="city" ngModel type="text" placeholder="City">
<input name="street" ngModel type="text" placeholder="Street">
</div>
<button type="submit" value="Submit">Sign Up</button>
</div>
</form>