Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- error TS2339: Property 'query' does not exist on type 'typeof CoreService'.
- import { CoreService} from "./../core.service";
- CoreService.query('login','POST',{username: this.username, password: this.password}).takeUntil(this.ngUnsubscribe).subscribe((value) => {
- });
- import { throwError as observableThrowError, interval as observableInterval, Observable, Subscription , Subject} from 'rxjs';
- import { tap, map } from 'rxjs/operators';
- import { Injectable } from '@angular/core';
- import { RequestOptions, URLSearchParams } from '@angular/http';
- import { HttpClient, HttpHeaders } from '@angular/common/http';
- import { environment } from './../environments/environment';
- import { Router, NavigationEnd, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
- @Injectable({providedIn: 'root'})
- export class CoreService {
- constructor(private http: HttpClient, private router: Router) {}
- result = {};
- permission = false;
- baseurl = environment.apiUrl;
- baseapi = this.baseurl + ':3000/api';
- options = {withCredentials: true};
- query(action,type,postdata) {
- // console.log("calling: " + type + " : " + action);
- if (type == 'POST') {
- return this.http.post(this.baseapi + "/" + action, postdata ,this.options).pipe(
- map(result => result),
- tap(result => this.result = result),);
- } else {
- return this.http.get(this.baseapi + "/" + action, this.options).pipe(
- map(result => result),
- tap(result => this.result = result),);
- }
- }
- performLogin(name: string, password: string) {
- var params = new URLSearchParams();
- params.append('username', name);
- params.append('password', password);
- return this.http.post(this.baseapi + '/login/login',params, this.options).pipe(
- map(result => result),
- tap(result => this.result = result),);
- }
- }
Add Comment
Please, Sign In to add comment