Is it possible to cache the HTTP requests in the Angular 10 version public getPart(id: any): Observable { return this.http.get(`${this.baseUrl}${id}`) .pipe(map((res: any) => res.data)); }
In this tutorial, we will see how can we achieve Real-Time Notification With Socket.io, Angular 10, and NodeJS. With WebSocket, we are allowed for full-duplex communication between a server and clients. WebSocket with socket.io The WebSocket goes beyond the typical HTTP request/response paradigm. With WebSockets, the server and client can send data without initiating a […]
In this tutorial, we will see what is the Best Way to Convert Angular 10 to Desktop App Using ElectronJS. Other than the PWA (Progressive Web App) we can also convert the angular app to an actual desktop app using the ElectronJS library. Angular 10 to Desktop App Using ElectronJS Using Electron we can easily […]
Add AuthInterceptor that will intercept all your HTTP requests and add the token to its headers: import { Injectable } from ‘@angular/core’; import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from ‘@angular/common/http’; import { Observable } from ‘rxjs’; @Injectable() export class AuthInterceptor implements HttpInterceptor { intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const token = localStorage.token; // […]
Multi-casting is the practice of broadcasting to a list of multiple subscribers in a single execution. Let’s demonstrate the multi-casting feature, var source = Rx.Observable.from([1, 2, 3]); var subject = new Rx.Subject(); var multicasted = source.multicast(subject); // These are, under the hood, `subject.subscribe({…})`: multicasted.subscribe({ next: (v) => console.log(‘observerA: ‘ + v) }); multicasted.subscribe({ next: (v) […]
How can I set the header in every request in angular? Let’s say I have token in localStorage and that needs to set for every REST API call.
How to use multicast of Rxjs in angular? It will be great if you can explain with an example.
What is AsyncPipe in angular and how to use it? It will be great if someone can explain with an example.
If the URL doesn’t match any predefined routes then it causes the router to throw an error and crash the app. In this case, you can use a wildcard route. A wildcard route has a path consisting of two asterisks to match every URL. For example, you can define PageNotFoundComponent for wildcard route as below: […]
How to define wildcard route in angular? I have to show page not found component if the URL doesn’t match anything.