-
-
Save supunlakmal/ed04fc1da234338b35d841059d45eaab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Component, | |
OnInit | |
} from '@angular/core'; | |
import { | |
Router, | |
RouterModule, | |
Routes | |
} from '@angular/router'; | |
import { | |
HttpClient, | |
HttpHeaders | |
} from '@angular/common/http'; | |
export class SystemComponent implements OnInit { | |
constructor( private http: HttpClient, private router: Router) {} | |
ngOnInit() { | |
const self = this; | |
const sendData = {}; | |
sendData['id'] = sessionStorage.getItem('id'); | |
console.log(JSON.stringify(sendData)); | |
const headers = new HttpHeaders() | |
.set('Content-Type', 'application/json') | |
.set('token', sessionStorage.getItem('auth') ? sessionStorage.getItem('auth') : 'thismyPc'); | |
this.http.post('http://thismypc.com:5000/auth', | |
JSON.stringify(sendData), { | |
headers | |
}) | |
.subscribe( | |
(val: any) => {}, | |
response => { | |
// if offline | |
this.router.navigate(['/login']); | |
}, | |
() => { | |
console.log('The POST observable is now completed.'); | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment