Я хочу взять, например, 100, но вернуть 5000 строк.и как можно использовать карту с.
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class PathsService {
path = 'https://jsonplaceholder.typicode.com/';
pathUser = this.path + 'users';
pathPost = this.path + 'posts';
pathContent = this.path + 'photos';
pathPostUserId = this.pathPost + '/?userId=';
constructor() { }
}
import { Injectable } from '@angular/core';
import { GetPosts } from '../entities/getPosts';
import { GetUsers } from '../entities/getUsers';
import { HttpClient } from '@angular/common/http';
import { GetDeneme } from '../entities/getdeneme';
import { PathsService } from './paths.service';
import { Observable } from 'rxjs';
import { map, take } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class GetdataService {
constructor(private http: HttpClient, private constsPath: PathsService) {
console.log(this.constsPath.pathPost);
console.log(this.constsPath.pathContent);
console.log(this.constsPath.pathUser);
console.log(this.constsPath.pathPostUserId);
}
getPosts(userid): Observable<GetPosts[]> {
if (userid) {
const link: string = this.constsPath.pathPostUserId + userid;
debugger;
return this.http.get<GetPosts[]>(link);
} else {
return this.http.get<GetPosts[]>(this.constsPath.pathPost);
}
}
getUsers(): Observable<GetUsers[]> {
return this.http.get<GetUsers[]>(this.constsPath.pathUser);
}
getContents(): Observable<GetDeneme[]> {
return this.http.get<GetDeneme[]>(this.constsPath.pathContent);
}
getProducts(seoUrl: string): Observable<GetDeneme[]> {
if (seoUrl) {
return this.http.get<GetDeneme[]>(this.constsPath.path + '/photos/' + seoUrl);
} else {
return this.http.get<GetDeneme[]>(this.constsPath.path + '/photos');
}
}
}
I want to take some for example 100 but return 5000 rows. and how can use map with
getPosts(): any {
debugger;
this.postService.getContents().pipe(take(100)).subscribe(res => {
this.getden = res;
});
};
Я добавил свой код службы блогов ссылка на сайт;https://jsonplaceholder.typicode.com/photos; Я смотрел https://www.learnrxjs.io/operators/filtering/take.html эта страница гайка, мой код не работает, или я не могу это сделать.Почему это не работает?