Photo by Branko Stancevic on Unsplash When you need to send an API call , be it GET, POST or any other http request call, you can incorporate the use of State Management implementation, such as NGXS. NGXS is a state management pattern + library for Angular . It acts as a single source of truth for your application's state, providing simple rules for predictable state mutations - NGXS documentation. Here is the example of sending a GET request through a service call. ngOnInit(): void { this.spinnerLoading = true; this.dataSource$ = this.postListService.getPosts(); this.getPostsData(); this.spinnerLoading = false; } getPostsData() { this.dataSource$.subscribe( ( res )...
A place for every software developer. Find solutions to your problem when it comes to setting up your project, Angular development, unit testing and many more.