Guest User

Untitled

a guest
May 24th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. error TS2339: Property 'query' does not exist on type 'typeof CoreService'.
  2.  
  3. import { CoreService} from "./../core.service";
  4.  
  5. CoreService.query('login','POST',{username: this.username, password: this.password}).takeUntil(this.ngUnsubscribe).subscribe((value) => {
  6.  
  7. });
  8.  
  9. import { throwError as observableThrowError, interval as observableInterval, Observable, Subscription , Subject} from 'rxjs';
  10. import { tap, map } from 'rxjs/operators';
  11.  
  12. import { Injectable } from '@angular/core';
  13. import { RequestOptions, URLSearchParams } from '@angular/http';
  14. import { HttpClient, HttpHeaders } from '@angular/common/http';
  15. import { environment } from './../environments/environment';
  16. import { Router, NavigationEnd, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
  17.  
  18. @Injectable({providedIn: 'root'})
  19. export class CoreService {
  20. constructor(private http: HttpClient, private router: Router) {}
  21.  
  22. result = {};
  23. permission = false;
  24. baseurl = environment.apiUrl;
  25. baseapi = this.baseurl + ':3000/api';
  26. options = {withCredentials: true};
  27.  
  28.  
  29.  
  30.  
  31. query(action,type,postdata) {
  32.  
  33. // console.log("calling: " + type + " : " + action);
  34. if (type == 'POST') {
  35. return this.http.post(this.baseapi + "/" + action, postdata ,this.options).pipe(
  36. map(result => result),
  37. tap(result => this.result = result),);
  38.  
  39.  
  40.  
  41. } else {
  42. return this.http.get(this.baseapi + "/" + action, this.options).pipe(
  43. map(result => result),
  44. tap(result => this.result = result),);
  45. }
  46.  
  47. }
  48.  
  49.  
  50.  
  51.  
  52. performLogin(name: string, password: string) {
  53. var params = new URLSearchParams();
  54. params.append('username', name);
  55. params.append('password', password);
  56.  
  57. return this.http.post(this.baseapi + '/login/login',params, this.options).pipe(
  58. map(result => result),
  59. tap(result => this.result = result),);
  60. }
  61.  
  62.  
  63.  
  64.  
  65. }
Add Comment
Please, Sign In to add comment