Adding
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import Axios from "axios";
|
||||
import { ILocationCoordinates } from "./service-types/LocationTypes";
|
||||
|
||||
export default class NetworkService {
|
||||
|
||||
public static FetchWithJSONP(url: string, JSONPFunctionIdentifier: string, callback: (data: any) => any) {
|
||||
const windowCallbackNamne = "bingMapLocationCallback";
|
||||
const jsonPUrl = url;
|
||||
|
||||
(window as any)[windowCallbackNamne] = (data: any) => {
|
||||
delete (window as any)[windowCallbackNamne];
|
||||
document.body.removeChild(script);
|
||||
callback(data);
|
||||
};
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.src = jsonPUrl;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
public static async FetchLocationData(url: string) {
|
||||
const result = await Axios.get(url);
|
||||
const locationResult = result.data as ILocationCoordinates;
|
||||
return locationResult;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user