import { DateFormat, dateToHuman } from '@app/helpers'
import { logger } from '@root-helpers/logger'
import { HttpStatusCode, ResultList } from '@shared/models'
+import { HttpHeaderResponse } from '@angular/common/http'
@Injectable()
export class RestExtractor {
convertDateToHuman (target: any, fieldsToConvert: string[], format?: DateFormat) {
fieldsToConvert.forEach(field => {
+ if (!target[field]) return
+
target[field] = dateToHuman(this.localeId, new Date(target[field]), format)
})
handleError (err: any) {
const errorMessage = this.buildErrorMessage(err)
- const errorObj: { message: string, status: string, body: string } = {
+ const errorObj: { message: string, status: string, body: string, headers: HttpHeaderResponse } = {
message: errorMessage,
status: undefined,
- body: undefined
+ body: undefined,
+ headers: err.headers
}
if (err.status) {