2

I am getting data from JSON file.

I want last modified datetime of that json file

here is how I am fetching data from JSON file

private _url = 'http://localhost:54362/app/output.json';
 this.http.get(this._url)
                    .toPromise()
                    .then((response) => {
                        this.jsonData = response.json();
                    }).catch((err) => {
                        console.log(err);
                    });

How can I get lastModified date ??

EDIT :

In header I am getting like this ...

console.log(response.headers._headers)


Map {"date" => ["Thu, 28 Dec 2017 08:29:15 GMT"], "etag" => [""8b6668d5a47fd31:0""], "last-modified" => ["Thu, 28 Dec 2017 06:26:45 GMT"], "server" => ["Microsoft-IIS/10.0"], "x-powered-by" => ["ASP.NET"]…}

How to access Last Modified date In this ???

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Aarsh
  • 2,555
  • 1
  • 14
  • 32
  • 1
    https://stackoverflow.com/questions/45505619/angular-4-3-3-httpclient-how-get-value-from-the-header-of-a-response should help you to read response headers. See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified – Günter Zöchbauer Dec 28 '17 at 08:02
  • As per your comment I made an edit to the post please check it out – Aarsh Dec 28 '17 at 08:45

1 Answers1

1

This should give you the last modified date from the headers

response.headers.get('last-modified')
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567