Posts

Showing posts with the label angular-httpclient

Angular HttpClient issue when calling Bing Maps Locations REST methods

Image
Clash Royale CLAN TAG #URR8PPP Angular HttpClient issue when calling Bing Maps Locations REST methods I have an existing call to Bing Maps made with Angular 4 Http service, that is working correctly: this.http.get(".../Locations?...&key=mykey") I'm trying to change the call to use the HttpClient service introduced in Angular 4.3, but when trying the same code: this.httpClient.get(".../Locations?...&key=mykey") then the request is sent with the preflight OPTIONS request, and bing maps obviously refuses it. I've tried to observe the request instead of the body, requesting a text response, and force the Accept header to text, but had no success. Headers of the Http request (working): Accept: application/json, text/plain, */* Origin: http://localhost:4200 Referer: http://localhost:4200/ User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36 Headers of the HttpClient request (not worki...

Angular 6 Http Interceptor only works on request with same port api request

Image
Clash Royale CLAN TAG #URR8PPP Angular 6 Http Interceptor only works on request with same port api request I am working on a SPA project with client side hosted separately with backend side. My angular project(client-side) is hosted on localhost:4200 and my web api (backend-side) is hosted on localhost:58395. I would like to create a logging/auth Interceptor through Angular 6 so I followed online tutorial and carefully tried in my own project. However, my logging interceptor or auth interceptor only will log the request with HttpClient.Get with api url in localhost:4200, although my web api request returned successfully but it's not being captured through my logging interceptor ...I am wondering if this is how interceptor works or if there is anything I did wrong on my side, if I cannot capture request to remote api I won't be able to log or attach my token... import { Injectable } from '@angular/core'; import { HttpInterceptor, HttpRequest, HttpHandler, HttpResponse }...