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.

2
  • 1
    This looks like it actually worked better than you would have expected. Can you show us a bit of your code? Commented May 2, 2017 at 20:59
  • Related: stackoverflow.com/a/14117744/3012385 Commented May 2, 2017 at 21:05

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

0

I was facing this issue in Angular 15. Reason was, I sending blank request to post rest API.

I fixed by sending random number in payload as:

let randomNo=Math.floor(Math.random() * (50 - 1 + 1)) + 1;

let payload= {randomNo:randomNo};

Comments

0

in some cases the cached headers go away by simply comment out the component rendered area in index.html file (better to do in the app component html file also) and un comment after a page reload

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.