post()

Call an HTTP function that is defined using the post prefix. For example, post_myFunction().

Learn more about post() HTTP functions.

Method Declaration

Copy
function post(functionName: string, options: postMethodOptions): Promise<postMethodResponse>;

Method Parameters

NameTypeDescription
functionNamestring requiredName of your site's HTTP function to call without its method prefix.
For example, for get_myFunction(), use myFunction.
optionsobjectAll properties of the options object are required as defined by your site's HTTP function.

options Properties

NameType
headersSupported types:
  • JSON object. For example, {"key1": "value1", "key2": "value2"}.
  • Array of arrays of tuples. For example, [['key1', 'value1'], ['key2', 'value2']].
  • Standard headers object.
paramsURLSearchParams object.
bodySupported types:

Returns

The response object from the site’s HTTP function.

Examples

Call a `post()` HTTP function with visitor/member access.
Copy
import { OAuthStrategy, createClient } from "@wix/sdk"; import { functions } from '@wix/http-functions'; const client = createClient({ auth: OAuthStrategy({ clientId: "MY_CLIENT_ID" }), modules: { functions }, }); async function callMyHttpFunction() { const response = await client.functions.post('myHttpFunction', options); }
Call a `post()` HTTP function with API Key access.
Copy
import { ApiKeyStrategy, createClient } from "@wix/sdk"; import { functions } from '@wix/http-functions'; const client = createClient({ auth: ApiKeyStrategy({ siteId: "MY-SITE-ID", apiKey: "MY-API-KEY", }), modules: { functions }, }); async function callMyHttpFunction() { const response = await client.functions.post('myHttpFunction', options); }
Did this help?