Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. {
  2. const id = this.actRoute.snapshot.paramMap.get('id');
  3.  
  4. this.studentApi.GetStudent(id).subscribe((res: any) => {
  5. console.log(res.data);
  6. this.subjectArray = res.data;
  7. console.log(this.subjectArray);
  8. this.studentForm = this.fb.group({
  9. id: [res.id, [Validators.required]],
  10. domain_id: [res.domain_id, [Validators.required]],
  11. source: [res.source, [Validators.required]],
  12. destination: [res.destination]
  13. });
  14. });
  15. }
  16.  
  17. GetStudent(id): Observable<any> {
  18. const API_URL = `${this.endpoint}/read-student/${id}`;
  19. return this.http.get(API_URL, { headers: this.headers })
  20. .pipe(
  21. map((res: Response) => {
  22. return res || {};
  23. }),
  24. catchError(this.errorMgmt)
  25. );
  26. }
  27.  
  28. studentRoute.get('/read-student/:id', (request, response) => {
  29. const id = request.params.id;
  30. con.query('SELECT * FROM students WHERE id = ?', id, (error, result) => {
  31. if (error) throw error;
  32. response.send(result);
  33. });
  34. });
  35.  
  36. [
  37. {
  38. "id": 5,
  39. "domain_id": 2,
  40. "source": "tester0700@test.pl",
  41. "destination": "testw@test.pl"
  42. }
  43. ]
  44.  
  45. this.studentApi.GetStudent(id).subscribe((res: any) => {
  46. console.log(res);
  47. this.subjectArray = res;
  48. // handle the rest here.
  49. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement