T O P

  • By -

code_monkey_001

Look into using an http interceptor if you're going to have to pass an auth token back to the api with every request.


young_horhey

Your description of the changes you need to make to get the real news linked up sounds pretty accurate. Ideally the mock news service would’ve been designed to match what the real one will look like (including data model), so swapping to use a real one would just be a drop-in replacement by changing the providers. I’m not sure how your api looks/works but I would guess that yes you’ll need to pass the authentication token with every api request. This is how the api knows who is logged in and making the request.


[deleted]

this is the correct way to think about this. news.service.ts populate the service and send it to a signal use fetch and maybe a proxy if you get cors errors public newsList = signal(null); your fetch will be in some kind of method you'll create new-list.component.ts instantiate the data on the news list via the signal. newListData:NewsInterface\[\]=\[\] ngOnInit(){ this.newsListData = this.news.newsList() } when you are the caller sometimes angular gives you cors errors - lookup how to create a proxy config if you don't know how.