This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Constants { | |
public static apiRoot = '/api', // If there is some prefix for all the APIs, then define that in constants. | |
public static API_VERSIONS = { | |
Version1: 'version1', | |
}; | |
public static pageSettings(): PageEvent { | |
return { | |
length: 0, | |
pageIndex: 0, | |
pageSize: 10, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { TodoItem, TodoItemCreate, TodoItemUpdate } from './models'; | |
import { Constants } from './constants'; | |
import { BaseService } from './base.service'; | |
@Injectable() | |
export class TodoService extends BaseService<TodoItem, TodoItemCreate, TodoItemUpdate> { | |
constructor(private readonly httpClient: HttpClient) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http'; | |
import { Observable, throwError } from 'rxjs'; | |
import urljoin from 'url-join'; | |
import { catchError } from 'rxjs/operators'; | |
/* | |
This should be placed in some miscellaneous folder. | |
*/ | |
export function constructApiVersionQueryParams(inputParams: HttpParams, apiVersion: string): HttpParams { | |
if (inputParams && inputParams.keys().length > 0) { |