Aarsh
Aarsh

Reputation: 2595

How to get last modified date of json file in angular 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 ???

Upvotes: 2

Views: 2659

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657258

This should give you the last modified date from the headers

response.headers.get('last-modified')

Upvotes: 1

Related Questions