import { getSearchQueryParamsAsObject } from "../getSearchQueryParamsAsObject/getSearchQueryParamsAsObject" ; import axios from "axios" ; import { XAPILaunchData } from "./XAPILaunchData" ; import { XAPILaunchParameters } from "./XAPILaunchParameters" ; export function getXAPILaunchData ( ) { if ( typeof location === "undefined" ) return Promise . reject ( new Error ( "Environment does not support location.search" ) ) ; const params = getSearchQueryParamsAsObject ( location . search ) ; if ( ! params . xAPILaunchService ) { return Promise . reject ( new Error ( "xAPILaunchService parameter not found in URL." ) ) ; } const launchURL = new URL ( params . xAPILaunchService ) ; launchURL . pathname += `launch/${ params . xAPILaunchKey }` ; return axios . request ( { method : "POST" , url : launchURL . toString ( ) , } ) . then ( ( response ) => { return response . data ; } ) ; }