angular-httpclient

Problem with Observable after update app to Angular 7 and RxJS 6.3.3

廉价感情. 提交于 2019-12-24 14:13:24
问题 I updated my app to Angular 7 and RxJS 6.3.3 and I've got a problems during making changes into my code. I really need help with that, because I can't to find solution into google or stack overflow. My imports: import { Observable, of } from 'rxjs'; import { map, catchError } from 'rxjs/operators'; import { Injectable, Inject, Optional, InjectionToken } from '@angular/core'; import { Headers, ResponseContentType, Response } from '@angular/http'; import { HttpClient } from '@angular/common

Angular HTTP Interceptor subscribing to observable and then returning next.handle but throwing TypeError: You provided 'undefined'

人盡茶涼 提交于 2019-12-24 07:27:27
问题 I have a HTTP interceptor and before every request I check if the access token is expired, if it is, I subscribe to a http.post call from my service and then subscribe to it and when I get a new access token I call next.handle(request) like this: this.auth.refreshAccessToken().subscribe((token: string) => { this.auth.newAccessToken = token; request = request.clone({ setHeaders: { Authorization: `Bearer ${token}` } }); return next.handle(request); }); The issue is then it is throwing TypeError

Why are my interval polling requests occurring only once?

霸气de小男生 提交于 2019-12-24 06:42:00
问题 I am trying to make a simple polling service using rxjs and angular 7 and am running into a recurring issue that my requests are only actually being fired once but the interval completes successfully with no errors. My service component looks like this: import { HttpClient, HttpHeaders, HttpRequest } from '@angular/common/http'; import { interval, Subject } from 'rxjs/index'; import { exhaustMap } from 'rxjs/internal/operators'; constructor( private httpClient: HttpClient ) { } getPing() {

Angular HttpClient Get method with body

六眼飞鱼酱① 提交于 2019-12-23 07:45:07
问题 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. The get method signature: @GetMapping("/subscribers") public ResponseEntity<List<SubscriberDTO>> getAllSubscribers(Pageable pageable, @RequestBody List<SearchCriteria> lstSearchCriteria) The implementation is working as expected tested on Postman Now I was going to Angular to implementing the front

Angular HttpClient Get method with body

江枫思渺然 提交于 2019-12-23 07:44:01
问题 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. The get method signature: @GetMapping("/subscribers") public ResponseEntity<List<SubscriberDTO>> getAllSubscribers(Pageable pageable, @RequestBody List<SearchCriteria> lstSearchCriteria) The implementation is working as expected tested on Postman Now I was going to Angular to implementing the front

Angular4 doesn't send post data

巧了我就是萌 提交于 2019-12-23 05:51:06
问题 Angular HttpClient doesnt send data to controller. I get a error 500 (because username in controller is null) when i try to execute fun(). test.sevice.ts import { Injectable } from '@angular/core'; import {HttpClient} from "@angular/common/http"; import 'rxjs/Rx'; import { Observable } from 'rxjs/Rx'; @Injectable() export class RestService { private EndPointUrl = 'http://127.0.0.1:8080/api/test'; constructor(public http: HttpClient){} fun(){ this.test().subscribe((data)=>console.log(data)); }

Angular4 file upload PUT request fails

拥有回忆 提交于 2019-12-23 04:39:34
问题 Angular4 file upload to PUT method fails but for POST it works fine. Any one having idea what's going on here?? HTML <input #fileSelect type="file" class="form-control" (change)="onFileUpload($event)" accept=".jpg, .png"/> COMPONENT imageToUpload: any; @ViewChild('fileSelect') fileSelectInput: ElementRef; onFileUpload(event) { this.imageToUpload = event.srcElement.files; } uploadImage() { let formData: FormData = new FormData(); formData.append('file', this.imageToUpload[0]); this.http.post

Angular Testing a service using HttpClient is not working for me

纵然是瞬间 提交于 2019-12-22 11:28:57
问题 I'm working on a Angular 5 Project, it's nothing serious. Though I've been out of the Angular2+ business since early 2.1/2.2. So I've got this Service which calls a public API, however my test keeps failing with: Error: Expected one matching request for criteria "Match URL: http://api.icndb.com/jokes/random/10", found none. code: fact.service.spec.ts import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing"; import {TestBed, inject} from "@angular/core

How to exclude some services like login, register from interceptor Angular 5, HttpClient

為{幸葍}努か 提交于 2019-12-22 02:56:45
问题 i wanted to exclude some services using interceptor. app.module.js providers: [ UserService, RolesService, { provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true }, ], Login.service.ts return this.httpClient.post(this.appUrl + '/oauth/token', body.toString(), { headers, observe: 'response' }) .map((res: Response) => { const response = res.body; this.storeToken(response); return response; }) .catch((error: any) => { ErrorLogService.logError(error); return Observable.throw(new

Angular 7 PWA + Azure Functions Gateway Timeout 504 only with Https

霸气de小男生 提交于 2019-12-21 13:08:48
问题 So the title pretty much says it all! I have an Angular 7 app compiled as PWA my package.json is below. My backend api is written in AzureFunctions V2. "dependencies": { "@angular-devkit/core": "^7.0.5", "@angular/animations": "^7.0.3", "@angular/cdk": "^7.0.3", "@angular/common": "^7.0.3", "@angular/compiler": "^7.0.3", "@angular/core": "^7.0.3", "@angular/flex-layout": "^7.0.0-beta.19", "@angular/forms": "^7.0.3", "@angular/http": "^7.0.3", "@angular/material": "^7.0.3", "@angular/platform