update recipe endpoint

This commit is contained in:
Kenta420-Poom 2023-09-25 16:59:10 +07:00
parent 9e8efa4cfc
commit e4fdf19c67
5 changed files with 76 additions and 14 deletions

View file

@ -4,16 +4,19 @@ import { BehaviorSubject, Observable, distinctUntilChanged } from 'rxjs';
import { Recipe } from '../models/recipe.model';
import { environment } from 'src/environments/environment';
interface Pagination {
interface RecipeParams {
offset: number;
take: number;
search: string;
}
@Injectable({ providedIn: 'root' })
export class RecipeService {
constructor(private _httpClient: HttpClient) {}
getRecipes(paginate: Pagination = { take: 10, offset: 0 }): Observable<{
getRecipes(
params: RecipeParams = { take: 10, offset: 0, search: '' }
): Observable<{
recipes: Recipe;
hasMore: boolean;
}> {
@ -22,10 +25,12 @@ export class RecipeService {
hasMore: boolean;
}>(environment.api + '/recipes', {
params: {
offset: String(paginate.offset),
take: String(paginate.take),
offset: params.offset,
take: params.take,
search: params.search,
},
withCredentials: true,
responseType: 'json',
});
}
}