Native Form
Submit JSON data via a native form, not AJAX. Useful when you need to open a new page with a POST action.
Installation
NPM
npm install @availity/native-form
Yarn
yarn add @availity/native-form
Usage
import nativeForm from '@availity/native-form';
async function onClick() {
await nativeForm(ssoId, params, formAttributes, type);
}
Required args
- ssoId: String. This is the id of the SSO that needs to be initiated. In the past this was sometimes referred to as
spaceIdbut do not confuse this id with the payer space id.
Optional args
- params: Object. Additional parameters you want sent in the post.
- formAttributes: Object. Set/override the form attributes like
target,method, andaction.methoddefaults to"post"actionwill default to/ms/api/availity/internal/spc/magneto/sso/v1/${typeLower}/${spaceId}wheretypeLoweris equal to"saml"or"openid"targetwill default to"\_blank"- Additional attributes can be defined and should be valid on an HTML form element
- type: String. Override the SSO integration type
- clientId: String. Set the
clientIdrequired for API Connect. Defaults to"clientId"
import nativeForm from '@availity/native-form';
async function onEvent() {
try {
await nativeForm(
'12312312312',
{ myExtraParam: 'myExtraParamValue' },
{ target: '_top' }
);
} catch (error) {
log(error);
}
}
When nativeForm is called it wil create a native HTML form and submit it.