angular-httpclient Questions

3

Solved

I have a project I migrated to Angular 18 with a setup to use the HttpClient by importing the HttpClientModule. @NgModule({ imports: [ BrowserModule, HttpClientModule, ... ], declarations: [ ...
Zootechnics asked 4/5 at 23:23

17

Solved

let httpParams = new HttpParams().set('aaa', '111'); httpParams.set('bbb', '222'); Why this doesn't work? It only set the 'aaa' and NOT the 'bbb' Also, I have an object { aaa: 111, bbb: 222 } How ...
Jilly asked 20/7, 2017 at 9:16

4

I use Observable.forkJoin() to handle the response after both HTTP calls finishes, but if either one of them returns an error, how can I catch that error? Observable.forkJoin( this.http.post<a...
Mischievous asked 29/6, 2018 at 14:18

3

Solved

For a school project I need to make a simple login page with Angular. When a login button is clicked I need to add an Authorization header with my post. I created a backend and when I post my Autho...
Chiarra asked 11/12, 2017 at 16:54

13

Solved

I try to send an POST request from Angular 4 to my Laravel backend. My LoginService has this method: login(email: string, password: string) { return this.http.post(`http://10.0.1.19/login`, { em...
Myrticemyrtie asked 25/9, 2017 at 15:8

7

I'm currently switching to the new HttpClient of Angular 4.3. One advantage is that I can specify a type info on the GET method and that the returned JSON is parsed into the given type, e.g. this....
Antlia asked 4/10, 2017 at 7:26

1

Solved

I'm creating a standalone app from scratch, I don't have an ngModule. I'm creating a translation service, and a pipe to use it. testing it on app.component.ts import { Component, OnInit } from '@an...
Tristatristam asked 23/9, 2023 at 15:45

9

Solved

I have been looking for a way to pass query parameters into an API call with the new HttpClientModule's HttpClient and have yet to find a solution. With the old Http module you would write somethin...
Perm asked 2/8, 2017 at 20:37

5

I am using latest version of angular (8). I am doing a conversion of my Http request from the original http to the new http client. I am calling a GET API where I am sending a nested params in the ...
Ambulator asked 14/11, 2019 at 11:40

4

Solved

How do I get the service code? I try the code below, but it does not log anything. In a service.ts file. constructor(private http: HttpClient) { } postForgotPass(email): Observable<Response&g...
Rabble asked 19/3, 2019 at 17:47

4

Solved

I Have an object which has a Date type property on client side. When I try to send object via HttpClient.post to server, property's value changes to UTC timezone. On client side value is Sun Nov 2...
Unreel asked 26/11, 2017 at 12:3

6

When I try to instantiate the HttpClient service in an external library, then consume that library in an Angular application, I'm getting StaticInjectorError errors: With Angular 5.0.0: AppCompon...
Unisexual asked 9/1, 2018 at 18:30

8

I have a very simple service call and a jasmine test for it. Service call: myServiceCall(testId: number) : void { const url = `${this.url}/paramX/${testId}`; this.http.put(url, {},{headers: th...
Oslo asked 8/6, 2018 at 7:53

3

How to get the status code of all the request using HttpClient apiCall() { let header1 = new HttpHeaders(); header1 = header1.append('Content-Type', 'application/json'); header1 = header1.append...
Ursel asked 9/11, 2021 at 12:56

4

Solved

I have exactly angular version 4.3.2 and I cannot update because of dependencies. So for now I stick to this version. I have object with dynamic params (there can be other keys and values inside): ...
Overwrite asked 10/10, 2017 at 8:26

0

i have implemented a global error tracking function in my angular application., there i gets this error occasionally ( whenever a user faces an error that error report will send to my db ) but most...
Pitchford asked 19/1, 2023 at 9:18

3

Solved

I have a use case whenever a new request is triggered, any http requests that are already in flight should be cancelled / ignored. For eg: A request (say #2) comes in while the request #1 t...
Competitive asked 28/2, 2018 at 18:17

3

In angular, we use HttpClient to make HTTP calls which return an observable, if we wanna use promises we can use lastValueFrom/firstValueFrom. Let's say we have: async getLast() { const get$ = thi...
Apposite asked 19/10, 2021 at 11:6

2

Solved

I am trying to implement a catch for 401 responses and tried obtaining a refresh token based on Angular 4 Interceptor retry requests after token refresh. I was trying to implement the same thing, b...
Flournoy asked 7/12, 2017 at 23:23

1

I have been reading a lot of topic about this issue on stackoverflow. Most of the answer saying that this is CORS problem. I am not sure in my case so that's why i ask this question again and need ...
Citify asked 14/1, 2020 at 17:51

13

Solved

I have a data service that looks like this: @Injectable() export class DataService { baseUrl = 'http://localhost' constructor( private httpClient: HttpClient) { } get(url, params): Promise&lt...
Recto asked 3/9, 2017 at 2:26

9

Solved

I need download an excel from my backend, its returned a file. When I do the request I get the error: TypeError: You provided 'undefined' where a stream was expected. You can provide an Observ...
Mckean asked 4/8, 2018 at 4:46

5

I'm improving an existing API, and the requirement is to provide a single get method which can accept multiple search criteria and based on those criteria perform the query. I'm using Spring MVC. ...
Darr asked 12/1, 2019 at 21:45

2

Solved

I am instantiating MyService in app.module.ts, and providing it throughout my code. However, I want MyService to use httpClient, and I am unable to angular-idiomatically instantiate httpClient to ...
Strapless asked 11/1, 2019 at 22:9

6

Solved

I'm getting a compilation error on the return type when using HttpClient. In my function GetPortfolio, I'm expecting the GET call to return the json object of type Observable<Portfolio> but i...
Vitrics asked 23/1, 2018 at 12:1

© 2022 - 2024 — McMap. All rights reserved.