angular-httpclient

How to make a massive delete in angular 4 with an array of ids

人盡茶涼 提交于 2021-02-20 04:12:33
问题 I'm trying to make a massive delete, in order to do that I have an Array<number> of the ids I want to delete. I can't pass this array as a parameter to the method this._httpService.delete(uri,options) . The type of _httpService is Http . So I'm looping the array and inside the loop I'm making single calls, but each call is async and I have certain logic to run when the loop ends. 回答1: Actually you can send the id array in the body of a DELETE request, according to this answer, like so: http

How to make a massive delete in angular 4 with an array of ids

情到浓时终转凉″ 提交于 2021-02-20 04:08:05
问题 I'm trying to make a massive delete, in order to do that I have an Array<number> of the ids I want to delete. I can't pass this array as a parameter to the method this._httpService.delete(uri,options) . The type of _httpService is Http . So I'm looping the array and inside the loop I'm making single calls, but each call is async and I have certain logic to run when the loop ends. 回答1: Actually you can send the id array in the body of a DELETE request, according to this answer, like so: http

How to make a massive delete in angular 4 with an array of ids

匆匆过客 提交于 2021-02-20 04:06:29
问题 I'm trying to make a massive delete, in order to do that I have an Array<number> of the ids I want to delete. I can't pass this array as a parameter to the method this._httpService.delete(uri,options) . The type of _httpService is Http . So I'm looping the array and inside the loop I'm making single calls, but each call is async and I have certain logic to run when the loop ends. 回答1: Actually you can send the id array in the body of a DELETE request, according to this answer, like so: http

How to make a massive delete in angular 4 with an array of ids

倾然丶 夕夏残阳落幕 提交于 2021-02-20 04:05:13
问题 I'm trying to make a massive delete, in order to do that I have an Array<number> of the ids I want to delete. I can't pass this array as a parameter to the method this._httpService.delete(uri,options) . The type of _httpService is Http . So I'm looping the array and inside the loop I'm making single calls, but each call is async and I have certain logic to run when the loop ends. 回答1: Actually you can send the id array in the body of a DELETE request, according to this answer, like so: http

Is there any way to alter the response in an Angular 5 HttpInterceptor?

我只是一个虾纸丫 提交于 2021-02-07 08:26:19
问题 For my application I have created the following HttpInterceptor . Is there a way to return an altered version of the response to the request subscribers from here? import { Injectable } from '@angular/core'; import { HttpRequest, HttpResponse, HttpErrorResponse, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { Router } from '@angular/router'; @Injectable() export class RequestInterceptor implements HttpInterceptor {

How to correctly subscribe Angular HttpClient Observable?

感情迁移 提交于 2021-01-29 13:55:37
问题 Taking example of HeroService from angular documentation. Below is a POST method in HeroService addHero (hero: Hero): Observable<Hero> { return this.http.post<Hero>(this.heroesUrl, hero, httpOptions) .pipe( catchError(this.handleError('addHero', hero)) ); } We can see that every time addHero is called a new Observable is returned. Ok now here is the service call from HeroComponent this.heroesService .addHero(newHero) .subscribe(hero => this.heroes.push(hero)); Now In my component this add

Angular 7: Post request always send a null body

梦想的初衷 提交于 2021-01-28 05:37:24
问题 I'm trying to understand this issue i had for days now, so i want to send a post request with username and password using angular 7 to a nodejs rest api for authentication but it sends an empty body here is the login method in authservice.ts: login(username: string, password: string): Observable<any> { let httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Accepts': 'application/json' }) }; return this.http.post<any>( `${this.HOST_DOMAINE}/bo/api/authenticate`, {

How to return HttpClient response body from a request?

两盒软妹~` 提交于 2021-01-28 05:06:48
问题 I have a component that relies on an API response for its content. I have set up the resolver but it still returns before my data is ready. How can I make my pull_categories() function wait until the response body is received and then return? Rather than returning an empty object because it won't wait or even call it in my case below. service.ts private _categories = []; constructor(private http: HttpClient) { } pull_categories() { this.http.post('https://myapi.com/something', null)

Angular 6 HttpInterceptor - when getting 401 refresh the token and create the same request

℡╲_俬逩灬. 提交于 2021-01-24 07:46:04
问题 I'm using the HttpInterceptor in Angular 6, and trying to built a refresh token mechanisim: When httpClient request get's 401 status code (unauthorised) the HttpInterceptor will create a request that will refresh the token, it will update the headers of the first request and call it again with the new token. The code is working until the stage that I need to recall the original request again with the new token that got from the refresh token request. This is my code: export class

Angular RxJS - How to monitor progress of HTTP Get Request (not file)

谁说胖子不能爱 提交于 2020-12-31 05:23:07
问题 How to utilize Angular HTTPClient's progress event to show progress in percentage of Get request which does not necessarily a file request? Currently HTTPClient's progress event fires after request completion. I am hoping to work with Content-Length at back end and determine percentage of content loaded at front end. I am loading a large amount of rows for a grid and need to show incremental progress on UI. Is it possible? 回答1: I know this question is older but, i stumbled upon this while