Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

Sending Data to Server using Express(Node.js)

$
0
0

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);
  }

I am facing this issue in ios

Viewing all articles
Browse latest Browse all 78072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>