HEX
Server: LiteSpeed
System: Linux server342.web-hosting.com 4.18.0-553.124.4.lve.el8.x86_64 #1 SMP Fri May 15 13:02:13 UTC 2026 x86_64
User: ksonpoau (1099)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //home/ksonpoau/www/wp-content/plugins/extendify/src/AutoLaunch/fetchers/get-launch-decisions.js
import { getLaunchDecisionsShape } from '@auto-launch/fetchers/shape';
import {
	failWithFallback,
	fetchWithTimeout,
	retryTwice,
} from '@auto-launch/functions/helpers';
import { AI_HOST } from '@constants';
import { reqDataBasics } from '@shared/lib/data';

const fallback = {
	launchDecisions: { navExtras: 'none', navButtonLabel: '' },
};
const url = `${AI_HOST}/api/launch-decisions`;
const method = 'POST';
const headers = { 'Content-Type': 'application/json' };

export const handleLaunchDecisions = async ({ siteProfile }) => {
	const body = JSON.stringify({ ...reqDataBasics, siteProfile });

	const response = await retryTwice(() =>
		fetchWithTimeout(url, { method, headers, body }),
	);

	if (!response?.ok) return fallback;

	return failWithFallback(
		async () => ({
			launchDecisions: getLaunchDecisionsShape.parse(await response.json()),
		}),
		fallback,
	);
};