【发布时间】:2021-11-04 18:15:49
【问题描述】:
Angular 12 - Httpclient jsonp - 如何传递自定义回调参数?
这是完整的应用程序 -> 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();
}
}
给出以下错误:
如何将回调参数值更改为 - https://geolocation-db.com/jsonp?callback=callback
但角度默认为https://geolocation-db.com/jsonp?callback=ng_jsonp_callback_1
【问题讨论】:
标签: typescript geolocation jsonp angular12