submit(submitContactFormProps: TSubmitContactFormProps): Promise<TResponseStatus | undefined>¶
The submit
method allows you to submit a contact form via api.
Input parameters¶
submitContactFormProps¶
submitContactFormProps
is a mandatory parameter of TSubmitContactFormProps type which includes the properties of a contact form message we are trying to send.
Returned value¶
A returned value is has a type of Promise<TResponseStatus | undefined>
. You can learn more about TResponseStatus here.
Example of usage¶
useStorefront(async (storefront) => {
const contactFormApi = storefront.getApiSync('ContactFormApi');
await contactFormApi.submit({
name: 'John Snow',
email: 'email@example.com',
subject: 'Example subject',
content: `Example content`
});
});
Example of usage with additional fields¶
useStorefront(async (storefront) => {
const contactFormApi = storefront.getApiSync('ContactFormApi');
await contactFormApi.submit({
name: 'John Snow',
email: 'email@example.com',
subject: 'Example subject',
content: `Example content`,
additional_1: '45',
additional_2: 'yes'
});
});