Skip to content

Instantly share code, notes, and snippets.

@teomanofficial
Created November 16, 2023 17:53
Show Gist options
  • Save teomanofficial/6764a3cdca9e65a7eae9ba30739584a5 to your computer and use it in GitHub Desktop.
Save teomanofficial/6764a3cdca9e65a7eae9ba30739584a5 to your computer and use it in GitHub Desktop.
Angular NGXS - ProductsService
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { GetProductsRequestModel } from "@store/products/models/get-products-request.model";
import { GetProductsResponseModel } from "@store/products/models/get-products-response.model";
@Injectable({ providedIn: 'root' })
export class ProductsService {
constructor(private readonly http: HttpClient) {
}
getProducts({ skip, limit } : GetProductsRequestModel) {
const params = { skip: skip ?? 0, limit: limit ?? 10 };
return this.http.get<GetProductsResponseModel>('products', { params })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment