Skip to content

Instantly share code, notes, and snippets.

@supunsandeeptha
Created May 24, 2019 18:41
Show Gist options
  • Save supunsandeeptha/fee55c0ae1d3f14e481e54928a64a0fe to your computer and use it in GitHub Desktop.
Save supunsandeeptha/fee55c0ae1d3f14e481e54928a64a0fe to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
import {HttpClient} from '@angular/common/http';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
name:any;
showResponse;
constructor(private HttpClient : HttpClient) {} //injecting the http client to the constructor
send(){
let sendName = {
name:this.name
}
this.HttpClient.post('http://localhost:9000/send',sendName).subscribe(
response =>{
console.log(response); //logging the response
let x = response;
this.showResponse = response;
alert(x);
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment