]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/rest/rest-extractor.service.ts
Fix bad date display for jobs
[github/Chocobozzz/PeerTube.git] / client / src / app / core / rest / rest-extractor.service.ts
index 7eec2eca62047901005dfc00a102b123f9e26dc4..de3f2bfff7f0cb64dd30d5db41ed7e45e4f73232 100644 (file)
@@ -4,6 +4,7 @@ import { Router } from '@angular/router'
 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 {
@@ -36,6 +37,8 @@ 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)
     })
 
@@ -54,10 +57,11 @@ export class RestExtractor {
   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) {