Angular 12 - Httpclient jsonp - how to pass custom callback parameter?
Here is the full app -> https://stackblitz.com/edit/angular-ivy-2zg5yt?file=src/app/geolocation.service.ts
geolocation-service.ts
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class GeolocationService {
constructor(private httpClient: HttpClient) {}
getLocation(): Observable<any> {
return this.httpClient
.jsonp<any>('https://geolocation-db.com/jsonp', 'callback')
.pipe();
}
}
Gives the following error:
How to change the callbackparam value to be - https://geolocation-db.com/jsonp?callback=callback
but angular is defaulting it to https://geolocation-db.com/jsonp?callback=ng_jsonp_callback_1
