Avatar ·

How to pass URL parameters (query string) in HTTP request in Angular?

Hi everyone! I'm new to Angular and TypeScript, and I can't figure out how to pass parameters in a GET request. I have a service that retrieves a list of users from the server. A regular request without parameters works fine: ```typescript getUsers(): Observable { return this.http.get('/api/users'); } ``` But now I need to add filtering: for example, pass parameters `page=1`, `limit=10`, and `search=john`. I tried just adding them to the URL string manually: ```typescript getUsers(page: number, search: string): Observable { return this.http.get(`/api/users?page=${page}&limit=10&search=${search}`); } ``` This works, but it looks kind of messy. First, if there are many parameters, the string becomes unreadable. Second, if any