I am new in angular2-Nativescript when i am sending data to server which is in Express(Node.js). Some function are able to send data to server but some function is not working.
Working Code
login(user: User) {
let headers = new Headers();
headers.append("Content-Type", "application/json");
return this._http.post(
Config.apiUrl + "login",
JSON.stringify({
email: user.email,
password: user.password
}),
{ headers: headers }
)
.map(response => response.json())
.map((response) => {
if (response.authentication == true) {
alert('Login Successful');
console.log("returning result = ", JSON.stringify(response.result));
console.log("response == ", JSON.stringify(response.result));
localStorage.setItem('userInfo1', JSON.stringify(response.result));
} else {
alert(response.message);
}
})
.catch(this.handleErrors);
}
Not Working Code
verify(user: User) {
console.log(JSON.stringify({ user }));
let headers = new Headers();
headers.append("Content-Type", "application/json");
return this._http.post(
Config.apiUrl + "verify",
JSON.stringify({
verificationCode: user.verificationCode
}),
{ headers: headers }
)
.map(response => response.json())
.map((response) => { })
.catch(this.handleErrors);
}