openaire-library/connect/projects/searchProjects.service.ts

23 lines
941 B
TypeScript
Raw Normal View History

import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import{EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class SearchCommunityProjectsService {
constructor(private http: HttpClient ) {}
searchProjects (properties:EnvProperties, communityId: string):any {
let url = properties.communityAPI+communityId+"/projects";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
//.map(res => <any> res.json())
}
countTotalProjects(properties:EnvProperties,communityId:string) {
let url = properties.communityAPI+communityId+"/projects";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => res['length']));
}
}