import { parseApiErrorMessage } from '../../../packages/shared/src/http'; import { fetchWithApiAuth, requestJson } from '../apiClient'; export async function requestRpgCreationPostJson( url: string, payload: unknown, fallbackMessage: string, ) { return requestJson( url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }, fallbackMessage, ); } export async function openRpgCreationSsePost( url: string, payload: unknown, fallbackMessage: string, ) { const response = await fetchWithApiAuth(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), }); if (!response.ok) { const responseText = await response.text(); throw new Error(parseApiErrorMessage(responseText, fallbackMessage)); } if (!response.body) { throw new Error('streaming response body is unavailable'); } return response; }