PluginProbe
Extendify / 3.1.4
Extendify v3.1.4
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / AutoLaunch / fetchers / get-launch-decisions.js

get-launch-decisions.js in Extendify 3.1.4, at src/AutoLaunch/fetchers/get-launch-decisions.js

33 lines 881 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { getLaunchDecisionsShape } from '@auto-launch/fetchers/shape';
2 import {
3 failWithFallback,
4 fetchWithTimeout,
5 retryTwice,
6 } from '@auto-launch/functions/helpers';
7 import { AI_HOST } from '@constants';
8 import { reqDataBasics } from '@shared/lib/data';
9
10 const fallback = {
11 launchDecisions: { navExtras: 'none', navButtonLabel: '' },
12 };
13 const url = `${AI_HOST}/api/launch-decisions`;
14 const method = 'POST';
15 const headers = { 'Content-Type': 'application/json' };
16
17 export const handleLaunchDecisions = async ({ siteProfile }) => {
18 const body = JSON.stringify({ ...reqDataBasics, siteProfile });
19
20 const response = await retryTwice(() =>
21 fetchWithTimeout(url, { method, headers, body }),
22 );
23
24 if (!response?.ok) return fallback;
25
26 return failWithFallback(
27 async () => ({
28 launchDecisions: getLaunchDecisionsShape.parse(await response.json()),
29 }),
30 fallback,
31 );
32 };
33