export const post = async ( action: string, additionalBodyArgs: Record | null = null ) => { const res = await fetch(window.ajaxurl, { method: 'POST', body: new URLSearchParams({ action, nonce: window.NSScottyPluginMantine.nonce, ...additionalBodyArgs, }), headers: { // form-data url encoded 'Content-Type': 'application/x-www-form-urlencoded', }, }); if (!res.ok) { throw { status: res.status, statusText: res.statusText }; } return res.json(); };