O'Reilly logo
  • Rajnesh tripathi thinks this is interesting:

Note that you don’t have to handle the error case of the API if you don’t want to (one advantage of promises).

This should work in your Angular app, but there’s a chance you may hit a CORS (cross-origin resource sharing) security issue. CORS is a security policy that browsers follow, instructing them to request data only from the same hostname the HTML is served from. There are ways to prevent this, but the best way for a MEAN app to do this is to serve posts.html from the API server.

This is a good idea for a lot of reasons; namely, it will allow you to use /api/posts instead of http://localhost:3000/api/posts in t...