request-util.ts 507B

12345678910111213141516171819
  1. import { HttpParams } from '@angular/common/http';
  2. export const createRequestOption = (req?: any): HttpParams => {
  3. let options: HttpParams = new HttpParams();
  4. if (req) {
  5. Object.keys(req).forEach(key => {
  6. if (key !== 'sort') {
  7. options = options.set(key, req[key]);
  8. }
  9. });
  10. if (req.sort) {
  11. req.sort.forEach(val => {
  12. options = options.append('sort', val);
  13. });
  14. }
  15. }
  16. return options;
  17. };