1

I was building angular's official 'heroes tutorial app' and instead of using their in-memory-data code, i tried using a json.placeholders (users) api so the app would be more real-world example.

Problem is when i change the official codes example url(in-memory-url) with the json.placeholder's api it just doesnt list the names and i checked the chrome dev console-network tab it shows status code 304,

By the way I am only trying to make a get request part of the tutorial, here is the error:

Request URL:https://jsonplaceholder.typicode.com/users
Request Method:GET
Status Code:304 
Remote Address:104.31.87.157:443
Referrer Policy:no-referrer-when-downgrade

Edit:

So i managed to list users from json.placeholder on the app with using observables from rxjs, then i changed it back to promise method official website shows that way and still not listing. Maybe it's something about the angular's promises i dont know.

However browsers network still showing 304 status. I am worrying that this could be a problem and it shouldn't be this way. So any help would be appreciated thanks.

Reşit Körsu
  • 578
  • 3
  • 8
  • 18

1 Answers1

3

HTTP 304 header code means "Not modified", it's not an error. According to the RFC 2616 of HTTP 1.1, the server only sends back headers, not the response which tells the browser to use the response that it had already in cache.

On the other hand, angular will always put 200 in status (even if it is a 304) and you shouldn't have to bother about keeping up to date your data, since you retrieve the fresher value each time (without bothering if it's from a cache in the server or fresh data from the server)

Id Add a random query string behind your url, that takes timestamp as the value. This way, each request will be considered a fresh one

Moreover id refer you to this topic

Boschko
  • 367
  • 5
  • 14